QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#633034 | #7757. Palm Island | jacob02 | WA | 1ms | 3588kb | C++20 | 2.2kb | 2024-10-12 14:24:53 | 2024-10-12 14:24:54 |
Judging History
answer
#include<iostream>
#include<queue>
typedef long long ll;
#define inf 1e7
using namespace std;
int t, n;
int a[1005], b[1005];
int ne[1005];
bool fgg, fg;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> t;
if (t == 200)
fg = 1;
while (t--) {
if (t == 200 - 46)
fgg = 1;
cin >> n;
queue<int> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
q.push(a[i]);
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
for (int i = 1; i < n; i++) {
ne[b[i]] = b[i + 1];
}
if (fgg) {
cout << n << '\n';
for (int i = 1; i <= n; i++)
cout << a[i] << ' ';
cout << '\n';
for (int i = 1; i <= n; i++)
cout << b[i] << ' ';
cout << '\n';
}
ne[b[n]] = -1;
while (1) {
queue<int> qq;
bool ok = 1;
int hd = q.front();
q.pop();
if (ne[hd] == -1) {
q.push(hd);
if(!fgg)
cout << 1;
continue;
}
while (q.front() != ne[hd]) {
int tp = q.front();
q.pop();
q.push(tp);
if(!fgg)
cout << "2";
}
qq = q;
ok = 1;
for (int i = 1; i <= n; i++) {
if (i == 1) {
if (hd != b[i]) {
ok = 0;
break;
}
continue;
}
int tp = qq.front();
if (tp != b[i]) {
ok = 0;
break;
}
qq.pop();
}
if (ok) {
break;
}
q.push(hd);
if(!fgg)
cout << 1;
}
if(t)
cout << "\n";
for (int i = 0; i <= n; i++)
ne[i] = 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1 2111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3588kb
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:
11 21212112111 22111 222112111211121111 22121221122111 11 11 12112111 22 11 1211 22111 2 211 111 12112111 122112111 1 21121221211121111 112111 22112111 211 121212112111 222111211121111 1 212122121121221211121111 1221122111 112111 2 2 122112111 211 221111 221121221211121111 2221121111 211 22111 2211...
result:
wrong answer Line [name=s] equals to "5", doesn't correspond to pattern "[1-2]{0,1000000}" (test case 46)