QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387804#7758. Painterberarchegas#RE 0ms0kbC++202.4kb2024-04-12 20:45:322024-04-12 20:45:33

Judging History

你现在查看的是最新测评结果

  • [2024-04-12 20:45:33]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-12 20:45:32]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
    
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
const ll INF = 2e18;

bool inv[1005][1005];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n), b(n), na, nb, posa(n + 1), posb(n + 1);
        for (int &x : a) cin >> x;
        for (int &x : b) cin >> x;
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                for (int j = i + 1; j < n; j++) {
                    na.push_back(a[j]);
                }
                for (int j = 0; j < i; j++) {
                    na.push_back(a[j]);;
                }
            }
            if (b[i] == 1) {
                for (int j = i + 1; j < n; j++) {
                    nb.push_back(b[j]);
                }
                for (int j = 0; j < i; j++) {
                    nb.push_back(b[j]);;
                }
            }
        }
        for (int i = 0; i < n - 1; i++) {
            posa[na[i]] = i;
            posb[nb[i]] = i;
        }
        int cnt = 0;
        for (int i = 2; i <= n; i++) {
            for (int j = 2; j <= n; j++) {
                if (posa[i] < posa[j] && posb[i] > posb[j]) inv[i][j] = true;
                if (posa[i] > posa[j] && posb[i] < posb[j]) inv[i][j] = true;
                cnt += inv[i][j];
            }
        }
        string ans;
        deque<int> v(n);
        for (int i = 0; i < n; i++) v[i] = a[i];
        while (cnt) {
            int f = v[0], s = v[1];
            cout << f << ' ' << s << endl;
            v.pop_front(), v.pop_front();
            if (inv[f][s]) {
                cnt--;
                inv[f][s] = inv[s][f] = false;
                ans += '2';
                v.push_front(f);
                v.push_back(s);
            }
            else {
                ans += '1';
                v.push_front(s);
                v.push_back(f);
            }
        }
        while (v[0] != b[0]) {
            ans += '1';
            int f = v[0];
            v.pop_front();
            v.push_back(f);
        }
        cout << ans << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

7
Circle 0 0 5 *
Circle -2 2 1 @
Circle 2 2 1 @
Rectangle 0 -1 0 0 ^
Rectangle -2 -2 2 -2 _
Render -5 -5 5 5
Render -1 0 1 2

output:


result: