Submission #6560251


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int p[200];
int main(){
	int n;cin>>n;
	rep(i,n){
		cin>>p[i];p[i]--;
	}
	rep(i,n)rep(j,n){
		swap(p[i],p[j]);
		bool ok=true;
		rep(k,n){
			if(p[k]!=k){ok=false;}
		}
		if(ok){
			puts("YES");return 0;
		}
		swap(p[i],p[j]);
	}
	puts("NO");
}

Submission Info

Submission Time
Task B - 0 or 1 Swap
User autumn_eel
Language C++14 (GCC 5.4.1)
Score 200
Code Size 502 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
All 200 / 200 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 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
testcase_0 1 ms 256 KB
testcase_1 1 ms 256 KB
testcase_10 1 ms 256 KB
testcase_11 1 ms 256 KB
testcase_2 1 ms 256 KB
testcase_3 1 ms 256 KB
testcase_4 1 ms 256 KB
testcase_5 1 ms 256 KB
testcase_6 1 ms 256 KB
testcase_7 1 ms 256 KB
testcase_8 1 ms 256 KB
testcase_9 1 ms 256 KB
testcase_add1 1 ms 256 KB