11941 | 2024-11-21 17:14:29 | matekimado11 | Kocsirendező | cpp17 | Wrong answer 0/100 | 35ms | 1336 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 | 320 KiB | ||||
4 | Wrong answer | 1ms | 320 KiB | ||||
5 | Wrong answer | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 348 KiB | ||||
7 | Wrong answer | 1ms | 320 KiB | ||||
8 | Wrong answer | 1ms | 388 KiB | ||||
9 | Accepted | 1ms | 568 KiB | ||||
10 | Wrong answer | 1ms | 500 KiB | ||||
11 | Wrong answer | 1ms | 320 KiB | ||||
12 | Wrong answer | 1ms | 320 KiB | ||||
13 | Wrong answer | 1ms | 320 KiB | ||||
14 | Wrong answer | 1ms | 320 KiB | ||||
15 | Wrong answer | 1ms | 320 KiB | ||||
16 | Wrong answer | 1ms | 408 KiB | ||||
17 | Wrong answer | 1ms | 320 KiB | ||||
18 | Wrong answer | 1ms | 332 KiB | ||||
19 | Wrong answer | 1ms | 320 KiB | ||||
20 | Wrong answer | 1ms | 320 KiB | ||||
21 | Wrong answer | 1ms | 320 KiB | ||||
22 | Wrong answer | 1ms | 648 KiB | ||||
23 | Wrong answer | 1ms | 512 KiB | ||||
24 | Wrong answer | 1ms | 320 KiB | ||||
25 | Wrong answer | 1ms | 332 KiB | ||||
subtask3 | 0/70 | ||||||
26 | Wrong answer | 1ms | 320 KiB | ||||
27 | Wrong answer | 1ms | 508 KiB | ||||
28 | Wrong answer | 2ms | 320 KiB | ||||
29 | Wrong answer | 3ms | 420 KiB | ||||
30 | Wrong answer | 4ms | 320 KiB | ||||
31 | Wrong answer | 8ms | 568 KiB | ||||
32 | Wrong answer | 8ms | 540 KiB | ||||
33 | Wrong answer | 18ms | 840 KiB | ||||
34 | Wrong answer | 32ms | 1088 KiB | ||||
35 | Wrong answer | 30ms | 1204 KiB | ||||
36 | Wrong answer | 32ms | 1208 KiB | ||||
37 | Wrong answer | 32ms | 1216 KiB | ||||
38 | Wrong answer | 35ms | 1336 KiB | ||||
39 | Wrong answer | 35ms | 1188 KiB |