# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
412094 | losmi247 | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
typedef long long ll;
const int N = 5002;
int n;
int *prvi,*drugi;
int *kojisvic;
int tryCombination(int *S){
for(int i = 0; i < n; i++){
if(S[i] != prvi[kojisvic[i]]) return i;
}
return -1;
}
void answer(int *S,int *D){
for(int i = 0; i < n; i++){
if(S[i] != prvi[i]){
cout << "WA1" << endl;
exit(0);
}
}
for(int i = 0; i < n; i++){
if(D[i] != drugi[i]){
cout << "WA2" << endl;
exit(0);
}
}
cout << "OK" << endl;
}
void znamred(){
int *niz = (int*)malloc(sizeof(int)*n);
int *odg1 = (int*)malloc(sizeof(int)*n);
for(int i = 0; i < n; i++){ niz[i] = 0; odg1[i] = i; }
while(1){
int x = tryCombination(niz);
if(x == -1) break;
niz[x] ^= 1;
}
answer(niz,odg1);
}
void exploreCave(int br){
n = br;
znamred();
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int gh;
cin >> gh;
prvi = (int*)malloc(sizeof(int)*gh);
drugi = (int*)malloc(sizeof(int)*gh);
kojisvic = (int*)malloc(sizeof(int)*gh);
for(int i = 0; i < gh; i++) cin >> prvi[i];
for(int i = 0; i < gh; i++){ cin >> drugi[i]; kojisvic[drugi[i]] = i; }
exploreCave(gh);
}*/