#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(int 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==-1) break;
// if(x==i+1){
// continue;
// }
// arr[i]=0;
// }
// 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
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
15 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
10 ms |
340 KB |
Output is correct |
7 |
Correct |
14 ms |
340 KB |
Output is correct |
8 |
Correct |
11 ms |
340 KB |
Output is correct |
9 |
Correct |
19 ms |
452 KB |
Output is correct |
10 |
Correct |
11 ms |
340 KB |
Output is correct |
11 |
Correct |
10 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Incorrect |
1 ms |
340 KB |
too much calls on tryCombination() |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |