QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603438#8838. Jesse's JobszcqwqWA 1ms5864kbC++141.1kb2024-10-01 16:34:092024-10-01 16:34:10

Judging History

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

  • [2024-10-01 16:34:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5864kb
  • [2024-10-01 16:34:09]
  • 提交

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 {
		printf("%d\n%d\n",n-2,n-1);
		for(int i=1;i<=n-1;++i) printf("%d ",i);
	}
	puts("");
}

int main()
{
	scanf("%d",&t);
	while(t--) {
		sol();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5864kb

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
5
1 2 3 4 5 

result:

wrong answer Participant didn't find permutation (test case 3)