QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#478887 | #8838. Jesse's Job | YMH_fourteen | RE | 0ms | 0kb | C++14 | 905b | 2024-07-15 12:14:15 | 2024-07-15 12:14:16 |
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