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 "cave.h"
#include<bits/stdc++.h>
using namespace std;
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
//subtask3
// void exploreCave(int N) {
// int n=N;
// int arr[N],ans[N];
// for(int i=0;i<n;i++) arr[i]=0;
// bool visited[N];
// memset(visited,false,sizeof(visited));
// int x=tryCombination(arr);
// dbg(x);
// for(int j=0;j<n;j++) cout<<arr[j]<<" ";
// cout<<endl;
// for(int i=0;i<n;i++){
// arr[i]=1;
// int x=tryCombination(arr);
// dbg(i,x);
// for( j=0;j<n;j++) cout<<arr[j]<<" ";
// cout<<endl;
// arr[i]=0;
// }
// for(int i=0;i<n;i++){
//first find 0
// int narr[n];
// for(int j=0;j<n;j++) narr[j]=arr[j];
// int x=tryCombination(narr);
// if(x==-1) break;
// for(int j=0;j<n;j++){
// if(visited[j]) continue;
// narr[j]=1;
// int x=tryCombination(narr);
// narr[j]=0;
// int x2=tryCombination(narr);
// if((x==i&&x2!=i)||(x!=i&&x2==i)){
// visited[j]=true;
// if(x==i&&x2!=i){
// arr[j]=0;
// continue;
// }else{
// arr[j]=1;
// continue;
// }
// }
// }
// }
// memset(ans,0,sizeof(ans));
// for(int i=0;i<n;i++){
// int narr[n];
// for(int j=0;j<n;j++) narr[j]=arr[j];
// narr[i]^=1;
// ans[i]=tryCombination(narr);
// }
// answer(arr,ans);
// }
//subtask1
void exploreCave(int N) {
int n=N;
int arr[N];
memset(arr,0,sizeof(arr));
for(int i=0;i<n;i++){
arr[i]=1;
int x=tryCombination(arr);
if(x==i) {
arr[i]=0;
}
else continue;
}
int ans[N];
for(int i=0;i<n;i++) ans[i]=i;
answer(arr,ans);
}
//subtask 2
// void exploreCave(int N) {
// /* ... */
// int n=N;
// int arr[N];
// memset(arr,0,sizeof(arr));
// int ans[N];
// for(int i=0;i<n;i++){
// arr[i]=1;
// int x=tryCombination(arr);
// ans[i]=x;
// arr[i]=0;
// }
// answer(arr,ans);
// }
#ifdef IOI
#include <stdio.h>
#include <stdlib.h>
#include "cave.h"
#define MAX_N 5000
#define MAX_CALLS 70000
#define fail(s, x...) do { \
fprintf(stderr, s "\n", ## x); \
exit(1); \
} while(0)
#define N koala
#define realS kangaroo
#define realD possum
#define inv platypus
#define num_calls echidna
static int N;
static int realS[MAX_N];
static int realD[MAX_N];
static int inv[MAX_N];
static int num_calls;
void answer(int S[], int D[]) {
int i;
int correct = 1;
for (i = 0; i < N; ++i)
if (S[i] != realS[i] || D[i] != realD[i]) {
correct = 0;
break;
}
if (correct)
printf("CORRECT\n");
else
printf("INCORRECT\n");
for (i = 0; i < N; ++i) {
if (i > 0)
printf(" ");
printf("%d", S[i]);
}
printf("\n");
for (i = 0; i < N; ++i) {
if (i > 0)
printf(" ");
printf("%d", D[i]);
}
printf("\n");
exit(0);
}
int tryCombination(int S[]) {
int i;
if (num_calls >= MAX_CALLS) {
printf("INCORRECT\nToo many calls to tryCombination().\n");
exit(0);
}
++num_calls;
for (i = 0; i < N; ++i)
if (S[inv[i]] != realS[inv[i]])
return i;
return -1;
}
int init() {
int i, res;
FILE *f = fopen("C:/Users/gss/inputf.in", "r");
if (!f)
fail("Failed to open input file.");
res = fscanf(f, "%d", &N);
for (i = 0; i < N; ++i) {
res = fscanf(f, "%d", &realS[i]);
}
for (i = 0; i < N; ++i) {
res = fscanf(f, "%d", &realD[i]);
inv[realD[i]] = i;
}
num_calls = 0;
return N;
}
signed main(){
int N;
N = init();
exploreCave(N);
printf("INCORRECT\nYour solution did not call answer().\n");
return 0;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |