Submission #985422

#TimeUsernameProblemLanguageResultExecution timeMemory
985422SzymonKrzywdaCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
//#include"cave.h" #include <bits/stdc++.h> using namespace std; const int n = 4; int licznik; int tryCombination(int S[]){ licznik ++; //for (int i=0; i<n; i++) cout << S[i] << " "; //cout << endl; //sleep(1); int good[n] = {1,1,1,0}; int good_2[n] = {3,0,1,2}; int mini = 1e7; for (int i=0; i<n; i++){ if (S[i] != good[i]) { //cout << good[i] << " " << S[i] << endl; mini = min(mini,good_2[i]); } } //cout << mini << endl; if (mini == 1e7) return -1; return mini; } void answer(int S[],int D[]){ for (int i=0; i<n; i++) cout << D[i]; cout << endl; for (int i=0; i<n; i++) cout << S[i]; cout << endl; cout << licznik; } void exploreCave(int N){ int D[N],S[N],w=0,w_2=0; for (int i=0; i<N; i++) D[i] = -1; bool good[N]; //int S_2[N]; // 0 0 0 0 0 // 1 1 1 1 1 // 1 1 1 1 0 //1110 //3102 //for (int i=0; i<N; i++) cout <<"dd"; for (int akt=0; akt<N; akt++){ for (int i=0; i<N; i++) if(D[i] == -1) S[i] = 0; w = tryCombination(S); //cout << i << " "<< w << endl; //if(w==-1) break; //if (w > i) continue; int l = 0,r=N-1,mid,key=1; while (l<r){ if (!(w == -1 || w > akt)){ for (int i=l; i<=r; i++){ if (D[i] == -1) S[i] = (S[i]+1)%2; } //w = tryCombination(S); } mid = (l+r)/2; for (int i=l; i<=mid; i++) if (D[i] == -1) S[i] = (S[i]+1)%2; w = tryCombination(S); if (w == akt){ r = mid; key = (S[l]+1)%2; } else{ l = mid+1; key = S[l]; } } D[l] = akt; S[l] = key; //cout << S[l]; /* for (int j=0; j<N; j++){ S[j] = (S[j]+1)%2; w_2 = tryCombination(S); if (w_2 == i){ D[j] = i; S[j] = (S[j]+1)%2; break; } S[j] = (S[j]+1%2); }*/ } /* for (int i=0; i<N; i++){ S[i] = (S[i]+1)%2; D[i] = tryCombination(S); S[i] = (S[i]+1)%2;*/ answer(S,D); /* int S_1[N]; int S_2[N]; for (int i=0; i<N; i++) S_2[i] = 1; bool good[N]; int do_zmiany[N]; for (int i=0; i<N; i++) do_zmiany[i] = -1; int w = 0,akt=0,w_2=0,ktory=0; while (w != -1){ if (akt == 0){ w = tryCombination(S_1); if (w == -1){ ktory = 0; break; } for (int i=0; i<N; i++){ if (!good[i]){ S_1[i] = 1; w_2 = tryCombination(S_1); if (w_2 == -1){ w = -1; ktory = 0; break; } if (w_2 < w){ S_2[i] = 0; S_1[i] = 0; good[i] = true; D[i] = w_2; w = tryCombination(S_1); } else if(w_2 > w){ good[i] = true; D[i] = w; w = w_2; } else S_1[i] = 0; } } } else{ w = tryCombination(S_2); if (w == -1){ ktory = 1; break; } for (int i=0; i<N; i++){ if (!good[i]){ S_2[i] = 0; w_2 = tryCombination(S_2); if (w_2 == -1){ w = -1; ktory = 1; break; } if (w_2 < w){ S_2[i] = 1; S_1[i] = 1; good[i] = true; D[i] = w_2; w = tryCombination(S_2); } else if(w_2 > w){ good[i] = true; D[i] = w; w = w_2; } else S_2[i] = 1; } } } akt = (akt+1)%2; //cout << good[0] << endl; //cout << w << endl; //cout << "GOOD: "; //for (int i=0; i<N; i++) cout << good[i] << " "; //cout << endl; } if (ktory == 0){ for (int i=0; i<N; i++){ S_1[i] = (S_1[i]+1)%2; if (!good[i]){ D[i] = tryCombination(S_1); } S_1[i] = (S_1[i]+1)%2; } answer(S_1,D); } else{ for (int i=0; i<N; i++){ S_2[i] = (S_2[i]+1)%2; if (!good[i]){ D[i] = tryCombination(S_2); } S_2[i] = (S_2[i]+1)%2; } answer(S_2,D); } */ }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:36:23: warning: unused variable 'w_2' [-Wunused-variable]
   36 |     int D[N],S[N],w=0,w_2=0;
      |                       ^~~
cave.cpp:38:10: warning: unused variable 'good' [-Wunused-variable]
   38 |     bool good[N];
      |          ^~~~
/usr/bin/ld: /tmp/cc3jOHVO.o: in function `main':
grader.c:(.text.startup+0x10): undefined reference to `exploreCave'
collect2: error: ld returned 1 exit status