Submission #6564299


Source Code Expand

Copy
#include <stdio.h>

int main(){
  int N;
  int p;
  int cnt = 0;
  
  scanf("%d",&N);

  for(int i=1;i<=N;i++){
    scanf("%d" ,&p);
    if( p != i )
      cnt++;
  }

  if( cnt == 0 || cnt == 2)
    printf("YES\n");
  else
    printf("NO\n");
  
  return 0;
}

Submission Info

Submission Time
Task B - 0 or 1 Swap
User FlatHarvest
Language C (GCC 5.4.1)
Score 200
Code Size 283 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:8:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&N);
   ^
./Main.c:11:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d" ,&p);
     ^

Judge Result

Set Name All Sample
Score / Max Score 200 / 200 0 / 0
Status
AC × 16
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_0, testcase_1, testcase_10, testcase_11, testcase_2, testcase_3, testcase_4, testcase_5, testcase_6, testcase_7, testcase_8, testcase_9, testcase_add1
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 128 KB
sample_02 AC 0 ms 128 KB
sample_03 AC 0 ms 128 KB
testcase_0 AC 0 ms 128 KB
testcase_1 AC 1 ms 128 KB
testcase_10 AC 1 ms 128 KB
testcase_11 AC 1 ms 128 KB
testcase_2 AC 1 ms 128 KB
testcase_3 AC 1 ms 128 KB
testcase_4 AC 1 ms 128 KB
testcase_5 AC 1 ms 128 KB
testcase_6 AC 1 ms 128 KB
testcase_7 AC 1 ms 128 KB
testcase_8 AC 1 ms 128 KB
testcase_9 AC 1 ms 128 KB
testcase_add1 AC 1 ms 128 KB