QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558477#7757. Palm IslandhhhhyfWA 0ms3616kbC++201.5kb2024-09-11 16:21:372024-09-11 16:21:43

Judging History

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

  • [2024-09-11 16:21:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-09-11 16:21:37]
  • 提交

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 = i; j + 1 < n; j ++, p ++) {
            if (a[j] < a[j + 1]) {
                s += '1';
            } else {
                swap(a[j], a[j + 1]);
                s += '2';
            }
        }
    }
    while (p) {
        s += '1';
        p = (p + 1) % n;
    }
    
    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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

input:

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

output:

221111
211111111111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

200
3
3 1 2
2 3 1
4
2 4 1 3
2 1 4 3
4
1 4 2 3
2 1 3 4
5
4 3 2 1 5
2 4 5 3 1
5
2 1 5 4 3
5 2 4 1 3
4
4 3 1 2
1 2 4 3
3
1 2 3
3 1 2
4
1 4 2 3
2 1 4 3
4
1 3 2 4
1 4 3 2
3
3 2 1
1 3 2
3
2 3 1
1 3 2
4
1 4 3 2
3 1 2 4
3
1 2 3
1 3 2
3
3 2 1
2 3 1
5
5 1 3 2 4
2 4 5 1 3
4
4 3 1 2
1 4 3 2
4
1 3 4 2
2 4 3 1
3
...

output:

121111
121111111111
122111111111
12121112111111111111
12211111111111111111
122111111111
121111
121111111111
112112111111
121111
221111
122111111111
121111
211111
11221122111111111111
121111111111
222112111111
221111
111111111111
21221122111111111111
122112111111
221111111111
212112111111
22211211111...

result:

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