QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478887#8838. Jesse's JobYMH_fourteenRE 0ms0kbC++14905b2024-07-15 12:14:152024-07-15 12:14:16

Judging History

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

  • [2024-07-15 12:14:16]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-15 12:14:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "E:/OI/normal/templates/debug.h"
#else
#define dbg(...) (void)0
#define msg(...) (void)0
#endif
#define ll long long
#define endl '\n'
#define PB emplace_back
#define PPB pop_back
#define MP make_pair
#define ALL(Name) Name.begin(),Name.end()
#define PII pair<int,int>
#define VI vector<int>
#define GI greater<int>
#define fi first
#define se second

const int N=1000005;
int n,a[N];
bool sol(int ans)
{
	VI lp;lp.PB(1);
	for(int i=a[1];i!=1;i=a[i])lp.PB(i);
	if(lp.size()==n)return 0;
	cout<<ans<<endl<<lp.size()<<endl;
	for(int i:lp)cout<<i<<" ";cout<<endl;
}

int main()
{
	ios::sync_with_stdio(false),cin.tie(nullptr);
	int _;cin>>_;while(_--)
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	if(!sol(n))
	{
		for(int i=1;i<=n;i++)if(a[i]<=2)a[i]^=3;
		assert(sol(n-2));
	}
}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

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

output:


result: