11948 | 2024-11-21 20:57:50 | lalala | Kocsirendező | cpp17 | Wrong answer 0/100 | 34ms | 792 KiB |
#include<iostream>
using namespace std;
int main()
{
int n,sz=0;
cin>>n;
n++;
int autok[n];
for(int i=1;i<n;i++)
{
cin>>autok[i];
}
for(int i=1;i<n;i++)
{
while(autok[i]!=i)
{
swap(autok[i],autok[autok[i]]);
sz++;
}
}
if(sz<2)cout<<"-1 \n";
else cout<<sz<<'\n';
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 0/30 | ||||||
3 | Wrong answer | 1ms | 500 KiB | ||||
4 | Wrong answer | 1ms | 320 KiB | ||||
5 | Wrong answer | 1ms | 508 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Wrong answer | 1ms | 320 KiB | ||||
8 | Wrong answer | 1ms | 320 KiB | ||||
9 | Accepted | 1ms | 320 KiB | ||||
10 | Wrong answer | 1ms | 320 KiB | ||||
11 | Wrong answer | 1ms | 320 KiB | ||||
12 | Wrong answer | 1ms | 324 KiB | ||||
13 | Wrong answer | 1ms | 320 KiB | ||||
14 | Wrong answer | 1ms | 508 KiB | ||||
15 | Wrong answer | 1ms | 320 KiB | ||||
16 | Wrong answer | 1ms | 356 KiB | ||||
17 | Wrong answer | 1ms | 320 KiB | ||||
18 | Wrong answer | 1ms | 320 KiB | ||||
19 | Wrong answer | 1ms | 320 KiB | ||||
20 | Wrong answer | 1ms | 320 KiB | ||||
21 | Wrong answer | 1ms | 320 KiB | ||||
22 | Wrong answer | 1ms | 320 KiB | ||||
23 | Wrong answer | 1ms | 320 KiB | ||||
24 | Wrong answer | 1ms | 320 KiB | ||||
25 | Wrong answer | 1ms | 508 KiB | ||||
subtask3 | 0/70 | ||||||
26 | Wrong answer | 1ms | 320 KiB | ||||
27 | Wrong answer | 1ms | 320 KiB | ||||
28 | Wrong answer | 2ms | 408 KiB | ||||
29 | Wrong answer | 3ms | 320 KiB | ||||
30 | Wrong answer | 4ms | 452 KiB | ||||
31 | Wrong answer | 8ms | 320 KiB | ||||
32 | Wrong answer | 8ms | 420 KiB | ||||
33 | Wrong answer | 18ms | 568 KiB | ||||
34 | Wrong answer | 30ms | 576 KiB | ||||
35 | Wrong answer | 30ms | 568 KiB | ||||
36 | Wrong answer | 30ms | 636 KiB | ||||
37 | Wrong answer | 32ms | 740 KiB | ||||
38 | Wrong answer | 34ms | 792 KiB | ||||
39 | Wrong answer | 34ms | 776 KiB |