QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686318 | #4937. Permutation Transformation | SanguineChameleon# | WA | 6ms | 4432kb | C++20 | 887b | 2024-10-29 11:10:18 | 2024-10-29 11:10:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define pb push_back
typedef pair<int,int> pii;
const int mxn = 1e5+5;
int nex[mxn];
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int n;
cin >> n;
for(int i=1;i<=n;i++){
int p;
cin>>p;
nex[i]=p;
}
int lc=0;
for(int i=1;i<=n;i++){
if(nex[i]==0)continue;
int c=0;
int u=i;
while(true){
int nn=nex[u];
nex[u]=0;
u=nn;
c++;
if(u==i)break;
}
lc = max(lc, c);
}
int ans=1;
int cyc_len=0;
for(int i=0;i<=n;i++){
if(cyc_len>=lc-1)break;
cyc_len+=(1ll<<i);
ans++;
}
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
5 3 5 1 2 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
8 7 5 1 6 8 2 3 4
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 6ms
memory: 4432kb
input:
100000 20864 34918 58550 1465 75674 30743 27235 88900 47488 50029 46054 84871 20330 72228 16506 44561 92519 97750 82891 60324 90508 39290 24663 38077 90189 30671 95476 64027 70888 90749 22566 8525 33675 16635 23392 97636 35788 89625 41966 78051 94034 15407 26545 83799 2233 10873 56946 71566 19045 44...
output:
17
result:
wrong answer 1st lines differ - expected: '216333199', found: '17'