QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558493#7757. Palm IslandhhhhyfWA 0ms3784kbC++201.5kb2024-09-11 16:29:542024-09-11 16:29:59

Judging History

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

  • [2024-09-11 16:29:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-09-11 16:29:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
void print() { cout << '\n'; }
template <typename T, typename...Args>
void print(T t, Args...args) { cout << t << ' '; print(args...); }
using ll = long long;
const int N = 1000001;

int dir[4][2] = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1}
};

template <typename T> bool chmax(T &x, T y) { if (y > x) { x = y; return true; } return false; }
template <typename T> bool chmin(T &x, T y) { if (y < x) { x = y; return true; } return false; }

template <typename T = int>
vector<T> readVector(int n) {
    vector<T> a(n);
    for(T &x: a) cin >> x, x --;
    return a;
} 

void solve () {
    int n;
    cin >> n;
    
    auto a = readVector(n);
    vector<int> f(n);
    for (int i = 0; i < n; i ++) {
        int x;
        cin >> x;
        x --;
        f[x] = i;
    }
    for (int& x: a) {
        x = f[x];
    }

    int p = 0;
    string s;
    for (int i = 0; i + 1 < n; i ++) {
        while (p != i) {
            s += '1';
            p = (p + 1) % n;
        }
        for (int j = 0; j + 1 < n - i; j ++, p ++) {
            if (a[j] < a[j + 1]) {
                s += '1';
            } else {
                swap(a[j], a[j + 1]);
                s += '2';
            }
        }
    }
    
    cout << s << '\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int t; 
	cin >> t;
	while(t --) {
	    solve();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3784kb

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

22111
21111111111

result:

wrong answer On Case#1: After your operations, a[1] = 1 but a[1] = 2. (test case 1)