QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#373493 | #5199. Amazing Trick | InfinityNS# | WA | 1ms | 3908kb | C++14 | 1.3kb | 2024-04-01 19:15:52 | 2024-04-01 19:15:53 |
Judging History
answer
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void test(){
int n;
scanf("%i",&n);
vector<int> a(n);
vector<int> pos(n);
for(int i=0;i<n;i++){
scanf("%i",&a[i]);
a[i]--;
pos[a[i]]=i;
}
vector<int> perm(n);
iota(all(perm),0);
int bound=0;
if(n<=2)bound=100;
else bound=10000;
for(int i=0;i<bound;i++){
shuffle(all(perm),rng);
bool ok=1;
for(int i=0;i<n;i++){
if(perm[i]!=a[i]&&perm[i]!=i){
}
else{
ok=0;
break;
}
}
if(!ok)continue;
printf("Possible\n");
vector<int> pos2(n);
for(int i=0;i<n;i++){
pos2[perm[i]]=i;
}
for(int i=0;i<n;i++){
printf("%i ",pos2[i]+1);
}
printf("\n");
for(int i=0;i<n;i++){
printf("%i ",pos[perm[i]]+1);
}
printf("\n");
return;
}
printf("Impossible\n");
}
int main(){
int t;
scanf("%i",&t);
while(t--){
test();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3908kb
input:
4 2 2 1 3 1 2 3 4 2 1 4 3 5 5 1 4 2 3
output:
Impossible Possible 3 1 2 2 3 1 Possible 3 4 1 2 4 3 2 1 Possible 4 1 2 5 3 4 5 1 2 3
result:
wrong answer Incorrect permuations p & q: a[p[q[1]]] = 3 (test case 4)