QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559501#8835. GoodmanAmanicus#WA 49ms11368kbC++14733b2024-09-11 22:34:032024-09-11 22:34:04

Judging History

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

  • [2024-09-11 22:34:04]
  • 评测
  • 测评结果:WA
  • 用时:49ms
  • 内存:11368kb
  • [2024-09-11 22:34:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llt __int128_t
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e2+10;
const int M = 1e6 + 7;
const int MAX = 0x3f3f3f3f;
const ll maxn = 1e18;
ll h,s1,vv,u,mi,mx,fz,fm,ans,item,f;
ll m,n,x,y,x2,y2,z,z2,d,gcd,l,r,T,p,cnt;
ll sum;
ll c[M];
ll a[N];
void solve() {
	vector<ll>b;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		c[i]=0;
	}
	for(ll i=1;i<=n;i++){
		if(c[i]){
			continue;
		}
		ll k=i;
		while(!c[k]){
			b.push_back(k);
			c[k]=1;
			k=a[k];
		}
	}
	for(auto it:b){
		cout<<it<<" ";
	}
	cout<<'\n';
}
int main() {
	IOS;
	T=1;
	cin>>T;
	while(T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4
1 2 3 4
6
6 5 4 3 2 1

output:

1 2 3 4 
1 6 2 5 3 4 

result:

ok Correct (2 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

873
6
1 5 2 4 6 3
6
5 1 6 4 3 2
4
1 4 3 2
6
2 1 6 5 4 3
6
4 5 1 3 6 2
6
6 2 1 5 4 3
5
1 5 4 3 2
6
1 2 6 3 5 4
4
2 1 3 4
6
1 6 4 2 3 5
6
6 1 3 5 2 4
6
2 1 4 5 3 6
6
3 4 1 5 2 6
6
4 1 5 2 6 3
6
5 2 1 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4 3 6 7 8 2 
1 2 4 7 3 5 6 8 
1 5 6 3 2 ...

result:

ok Correct (46233 test cases)

Test #4:

score: -100
Wrong Answer
time: 49ms
memory: 11368kb

input:

1
999995
992870 548521 579550 387108 249895 990007 476463 686591 907510 311379 340877 491996 478527 996443 681309 483046 760005 905577 711115 275827 697004 737465 904964 381424 774578 217570 554656 914370 935328 624905 590395 761191 265062 978389 670994 184745 662928 389422 952905 447853 325275 9796...

output:

999884 999885 999886 999887 999888 999889 999890 999891 999892 999893 999894 999895 999896 999897 999898 999899 999900 999901 999902 999903 999904 999905 999906 999907 999908 999909 999910 999911 999912 999913 999923 999914 999915 999916 999917 999918 999919 999920 999921 999922 999924 999925 999926...

result:

wrong output format Unexpected end of file - int32 expected (test case 1)