제출 #627794

#제출 시각아이디문제언어결과실행 시간메모리
627794peti1234드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "insects.h" const int c=2005; int cnt, si, ord[c]; bool v[c], fix[c]; int add(int a) { assert(!v[a]); v[a]=true; si++; move_inside(a); return press_button(); } void sub(int a) { assert(v[a]); v[a]=false; si--; move_outside(a); } int min_cardinality(int N) { for (int i=0; i<N; i++) { ord[i]=i; } random_shuffle(ord, ord+N); for (int i=0; i<N; i++) { if (add(i)==2) { sub(i); } else { cnt++; } } for (int i=0; i<N; i++) { if (v[i]) { fix[i]=1; } } int lo=1, hi=N/cnt+1, mid; while (hi-lo>1) { mid=(hi+lo)/2; for (int i=0; i<N; i++) { int pos=ord[i]; if (fix[pos] || si==cnt*mid) continue; if (add(pos)>mid) { sub(pos); } } if (si==cnt*mid) { lo=mid; for (int i=0; i<N; i++) { if (v[i]) { fix[i]=1; } } } else { hi=mid; for (int i=0; i<N; i++) { if (fix[i]) continue; if (!v[i]) fix[i]=1; else { sub(i); } } } } return lo; } /* int main() { return 0; } */#include <bits/stdc++.h> using namespace std; #include "insects.h" const int c=2005; int cnt, si, ord[c]; bool v[c], fix[c]; int add(int a) { assert(!v[a]); v[a]=true; si++; move_inside(a); return press_button(); } void sub(int a) { assert(v[a]); v[a]=false; si--; move_outside(a); } int min_cardinality(int N) { for (int i=0; i<N; i++) { ord[i]=i; } random_shuffle(ord, ord+N); for (int i=0; i<N; i++) { if (add(i)==2) { sub(i); } else { cnt++; } } for (int i=0; i<N; i++) { if (v[i]) { fix[i]=1; } } int lo=1, hi=N/cnt+1, mid; while (hi-lo>1) { mid=(hi+lo)/2; for (int i=0; i<N; i++) { int pos=ord[i]; if (fix[pos] || si==cnt*mid) continue; if (add(pos)>mid) { sub(pos); } } if (si==cnt*mid) { lo=mid; for (int i=0; i<N; i++) { if (v[i]) { fix[i]=1; } } } else { hi=mid; for (int i=0; i<N; i++) { if (fix[i]) continue; if (!v[i]) fix[i]=1; else { sub(i); } } } } return lo; } /* int main() { return 0; } */

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp:78:11: error: redefinition of 'const int c'
   78 | const int c=2005;
      |           ^
insects.cpp:5:11: note: 'const int c' previously defined here
    5 | const int c=2005;
      |           ^
insects.cpp:79:5: error: redefinition of 'int cnt'
   79 | int cnt, si, ord[c];
      |     ^~~
insects.cpp:6:5: note: 'int cnt' previously declared here
    6 | int cnt, si, ord[c];
      |     ^~~
insects.cpp:79:10: error: redefinition of 'int si'
   79 | int cnt, si, ord[c];
      |          ^~
insects.cpp:6:10: note: 'int si' previously declared here
    6 | int cnt, si, ord[c];
      |          ^~
insects.cpp:79:14: error: redefinition of 'int ord [2005]'
   79 | int cnt, si, ord[c];
      |              ^~~
insects.cpp:6:14: note: 'int ord [2005]' previously declared here
    6 | int cnt, si, ord[c];
      |              ^~~
insects.cpp:80:6: error: redefinition of 'bool v [2005]'
   80 | bool v[c], fix[c];
      |      ^
insects.cpp:7:6: note: 'bool v [2005]' previously declared here
    7 | bool v[c], fix[c];
      |      ^
insects.cpp:80:12: error: redefinition of 'bool fix [2005]'
   80 | bool v[c], fix[c];
      |            ^~~
insects.cpp:7:12: note: 'bool fix [2005]' previously declared here
    7 | bool v[c], fix[c];
      |            ^~~
insects.cpp:81:5: error: redefinition of 'int add(int)'
   81 | int add(int a) {
      |     ^~~
insects.cpp:8:5: note: 'int add(int)' previously defined here
    8 | int add(int a) {
      |     ^~~
insects.cpp:88:6: error: redefinition of 'void sub(int)'
   88 | void sub(int a) {
      |      ^~~
insects.cpp:15:6: note: 'void sub(int)' previously defined here
   15 | void sub(int a) {
      |      ^~~
insects.cpp:94:5: error: redefinition of 'int min_cardinality(int)'
   94 | int min_cardinality(int N) {
      |     ^~~~~~~~~~~~~~~
insects.cpp:21:5: note: 'int min_cardinality(int)' previously defined here
   21 | int min_cardinality(int N) {
      |     ^~~~~~~~~~~~~~~