QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#603487 | #8838. Jesse's Job | szcqwq | WA | 1ms | 5848kb | C++14 | 1.1kb | 2024-10-01 16:52:36 | 2024-10-01 16:52:38 |
Judging History
answer
#include <bits/stdc++.h>
//#include <windows.h>
#define ED cerr<<endl;
#define TS cerr<<"I AK IOI"<<endl;
#define cr(x) cerr<<x<<endl;
#define cr2(x,y) cerr<<x<<" "<<y<<endl;
#define cr3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<endl;
#define cr4(x,y,z,w) cerr<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
#define ll long long
//#define ull unsigned long long
using namespace std;
const int N=1e6+5,INF=2e9,mod=1e9+7;
int t,n,m;
int ne[N],vis[N];
vector<int> s;
void sol() {
scanf("%d",&n);
for(int i=1;i<=n;++i) {
scanf("%d",&ne[i]);
vis[i]=0;
}
int cnt=0;
for(int i=1;i<=n;++i) {
if(!vis[i]) {
int p=i;++cnt;
s.clear();
while(!vis[p]) {
s.emplace_back(p);
vis[p]=1,p=ne[p];
}
}
}
if(cnt==2) {
printf("%d\n%d\n",n,s.size());
for(auto it:s) printf("%d ",it);
}
else {
int mx=-INF,id=0;
for(int i=1;i<=n;++i) {
int val=n-1-abs(ne[i]-i);
if(val>mx) mx=val,id=i;
}
printf("%d\n1\n%d",mx,id);
}
puts("");
}
int main()
{
scanf("%d",&t);
while(t--) {
sol();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5844kb
input:
3 2 2 1 4 2 1 4 3 6 3 5 4 2 6 1
output:
0 1 1 4 2 3 4 4 1 3
result:
ok Correct (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5848kb
input:
872 6 1 5 2 6 3 4 6 5 2 1 3 4 6 4 2 1 3 4 6 2 3 1 4 5 6 6 4 5 1 6 2 3 6 6 2 3 1 4 5 5 2 1 3 4 5 6 1 2 6 4 3 5 4 2 1 4 3 6 1 6 4 2 5 3 6 6 1 3 5 4 2 6 2 1 4 5 6 3 6 3 4 1 5 6 2 6 4 1 5 3 2 6 6 5 2 1 6 3 4 6 4 1 6 2 5 3 6 5 1 3 6 2 4 6 6 2 5 4 3 1 6 6 2 5 3 1 4 6 5 2 4 1 3 6 6 6 1 3 2 4 5 6 2 3 4 6 5 ...
output:
5 1 1 5 1 2 3 1 3 5 1 4 6 2 2 5 5 1 2 4 1 3 5 1 1 4 2 3 4 5 1 1 5 1 3 6 4 3 4 5 6 6 4 2 4 5 6 6 1 6 5 1 2 5 1 5 5 1 3 5 1 2 6 1 2 5 1 2 6 1 3 6 1 5 6 1 4 5 1 2 4 1 2 5 1 2 5 1 1 5 1 1 5 1 1 4 1 2 5 1 6 6 1 3 5 1 1 5 1 4 6 1 3 2 1 2 4 1 3 5 1 2 4 1 1 6 1 4 5 1 2 6 3 2 6 4 6 3 2 6 3 4 1...
result:
wrong answer Participant didn't find permutation (test case 1)