先讲题目,再发私货

A、俄罗斯方块

直接用底板向下探,如果探到底,或者现在这个地方以及有1了解释探底,回调一个位置。
再注意一下各个方块的形状就行了。

私货:cao,我的算法一点错没有,出题人多了半厘米表示三号图底板四个格子,也不说,样例也不表示,给我整吐了,半天。

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar(); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[200]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-'); int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';     tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;   while (b) { if (b & 1)  ans *= a;       b >>= 1;      a *= a; }   return ans; }   ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

const int N = 15;
int mp[N][N];
int n, m;

int main() {
    n = read();
    while (n--) {
        int op = read(), x = read();
        if (op == 1) {
            int i = 1;
            for (; i <= 10; ++i)
                if (mp[i][x] || mp[i][x + 1])   break;
            --i;
            mp[i][x] = mp[i][x + 1] = mp[i - 1][x] = mp[i - 1][x + 1] = 1;
        }
        else if (op == 2) {
            int i = 1;
            for (; i <= 10; ++i)
                if (mp[i][x] || mp[i][x + 1] || mp[i][x + 2])   break;
            --i;
            mp[i][x] = mp[i][x + 1] = mp[i][x + 2] = mp[i - 1][x] = 1;
        }
        else if (op == 3) {
            int i = 1;
            for (; i <= 10; ++i)
                if (mp[i][x] || mp[i][x + 1] || mp[i][x + 2] || mp[i][x + 3])   break;
            --i;
            mp[i][x] = mp[i][x + 1] = mp[i][x + 2] = mp[i][x + 3] = 1;
        }
        else if (op == 4) {
            int i = 1;
            for (; i <= 10; ++i)
                if (mp[i][x] || mp[i][x + 1] || mp[i][x + 2])   break;
            --i;
            mp[i][x] = mp[i][x + 1] = mp[i][x + 2] = mp[i - 1][x + 1] = 1;
        }
    }
    for (int i = 1; i <= 10; ++i)
        for (int j = 1; j <= 10; ++j)
            printf("%d%c", mp[i][j], " \n"[j == 10]);
    return 0;
}

B、真的是签到题

真的是签到题。

print('''NUC2020!!!
NUC2020!!!
NUC2020!!!''')

E、简单的线性代数

第一次知道矩阵还能当成一个数处理……
那就相当于一个的等比数列前项和图片说明

化简一下就是了。

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define int long long
typedef long long ll;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();    return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[200]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

const int N = 1e3 + 7;
int a[N][N];

signed main() {
    int n = read(), m = read();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)    a[i][j] = read();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            printf("%d%c", (i == j) - a[i][j], " \n"[j == n]);
    return 0;
}

F、集合操作

5S时间,出题人给了操作空间。如果直接按照set的性质插入就插入,最后查找可能会出来一个连续区间,线性找最后元素,这个地方会

那插入删除都可以,麻烦就是找大于等于的最小值,那如果我们一开始离线吧全部处理的值都放进去呢?
吧x以及可能的找到的x+1一来进放进set里面去。
之后每次插入一个值,就代表这个不可能是答案,在set中删除这个值。
删除一个值,代表可能可以找到答案,插入这个值。
最后查找,直接二分找下界即可。

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define int long long
typedef long long ll;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();    return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[200]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

const int N = 1e6 + 7;
set<int> st;
int op[N], x[N];

signed main() {
    int n = read();
    for (int i = 1; i <= n; ++i) {
        op[i] = read(), x[i] = read();
        st.insert(x[i]);
        st.insert(x[i] + 1);
    }
    for (int i = 1; i <= n; ++i) {
        if (op[i] == 1)    st.erase(x[i]);
        else if (op[i] == 2)    st.insert(x[i]);
        else {
            auto it = st.lower_bound(x[i]);
            write(*it), putchar(10);
        }
    }
    return 0;
}

G、数位操作1

第一特判小于10的数,直接输出,第二对n从9开始向下试因子,吧全部可能的因子存起来即可。如果最后n没有被除尽说明是个大于10的素数因子

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar(); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[200]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-'); int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';     tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;   while (b) { if (b & 1)  ans *= a;       b >>= 1;      a *= a; }   return ans; }   ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

const int N = 15;
int a[N];

int main() {
    js;
    ll n;
    while (cin >> n) {
        if (n < 10) {
            cout << 1 << n << '\n';
            continue;
        }
        memset(a, 0, sizeof(a));
        for (int i = 9; i > 1; --i)
            while (n % i == 0)  ++a[i], n /= i;
        if (n != 1) cout << -1 << endl;
        else {
            for (int i = 2; i < 10; ++i)
                for (int j = 0; j < a[i]; ++j)
                    cout << i;
            cout << '\n';
        }
    }
    return 0;
}

K、签个到

一定是只对一个数进行同一种操作,最终答案才会最大,分散没有意义。
首先找到输入数据中的最大值和最小值。
再去找最大值减掉某个数变小m个pos,或者某个数变大m个pos减掉最小值。全部遍历一下找最大即可。
注意特判n=1情况。

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll;
const ll MOD = 1e9 + 7;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();    return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[200]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

const int N = 1e5 + 7;
const ll INF = 1e18;
ll a[N];

int main() {
    ll n = read(), m = read();
    ll mini = INF, maxi = -INF;
    for (int i = 1; i <= n; ++i) {
        a[i] = read();
        mini = min(mini, a[i]);
        maxi = max(maxi, a[i]);
    }
    if (n == 1)    return write(0), 0;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, maxi - a[i] + m * i);
        ans = max(ans, a[i] + m * i - mini);
    }
    write(ans), putchar(10);
    return 0;
}