Submission #31080

#TimeUsernameProblemLanguageResultExecution timeMemory
31080WhipppedCreamCave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include "grader.c" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define pb push_back bool solved[5005]; int sol[5005]; int connect[5005]; int arr[5005]; int tmp[5005]; vi cand; void exploreCave(int n) { for(int i = 0; i< n; i++) cand.pb(i); for(int it = 0; it< n-1; it++) { //printf("-----iteration %d\n", it); for(int i = 0; i< n; i++) if(solved[i]) arr[i] = sol[i]; for(int i = 0; i< (int) cand.size(); i++) arr[cand[i]] = 0; int last = tryCombination(arr); if(last == -1) last = 1e9; int L = 0, R = cand.size()-1; memset(tmp, 0, sizeof tmp); while(L< R) { //printf("L = %d and R = %d\n", L, R); int mid = (L+R)/2; for(int i = 0; i< n; i++) if(solved[i]) arr[i] = sol[i]; for(int i = mid+1; i<= R; i++) if(!solved[cand[i]]) arr[cand[i]] = 1-arr[cand[i]]; int x = tryCombination(arr); if(x == -1) x = 1e9; if(x< last) { L = mid+1; last = x; if(L == R) sol[cand[L]] = 1-arr[cand[L]]; } else if(x> last) { L = mid+1; if(L == R) sol[cand[L]] = arr[cand[L]]; for(int i = mid+1; i<= R; i++) if(!solved[cand[i]]) arr[cand[i]] = 1-arr[cand[i]]; } else { int trex = R; R = mid; if(L == R) sol[cand[L]]= 1-arr[cand[L]]; for(int i = mid+1; i<= trex; i++) if(!solved[cand[i]]) arr[cand[i]] = 1-arr[cand[i]]; } } connect[cand[L]] = last; solved[cand[L]] = 1; //printf("connect %d to %d\n", cand[L], last); //printf("position for %d is %d\n", cand[L], sol[cand[L]]); cand.erase(cand.begin()+L); } int pos = cand[0]; //printf("pos is %d\n", pos); memset(arr, 0, sizeof arr); for(int i = 0; i< n; i++) if(solved[i]) arr[i] = sol[i]; int x = tryCombination(arr); int y; if(x == -1) { arr[pos] = 1-arr[pos]; y = tryCombination(arr); sol[pos] = 1-arr[pos]; } else { y = x; sol[pos] = 1-arr[pos]; } connect[pos] = y; answer(sol, connect); }

Compilation message (stderr)

In file included from grader.c:1:0,
                 from cave.cpp:1:
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:11:4: error: expected unqualified-id before 'while'
  } while(0)
    ^
/usr/include/c++/7/bits/basic_ios.h: In member function 'std::basic_ios<_CharT, _Traits>::operator bool() const':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ';' before 'do'
/usr/include/c++/7/bits/basic_ios.h: In member function 'bool std::basic_ios<_CharT, _Traits>::operator!() const':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ';' before 'do'
/usr/include/c++/7/bits/ostream.tcc: In member function 'std::basic_ostream<_CharT, _Traits>::pos_type std::basic_ostream<_CharT, _Traits>::tellp()':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ')' before 'do'
/usr/include/c++/7/bits/ostream.tcc: In member function 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::seekp(std::basic_ostream<_CharT, _Traits>::pos_type)':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ')' before 'do'
/usr/include/c++/7/bits/ostream.tcc: In member function 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::seekp(std::basic_ostream<_CharT, _Traits>::off_type, std::ios_base::seekdir)':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ')' before 'do'
/usr/include/c++/7/bits/istream.tcc: In member function 'std::basic_istream<_CharT, _Traits>::pos_type std::basic_istream<_CharT, _Traits>::tellg()':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ')' before 'do'
/usr/include/c++/7/bits/istream.tcc: In member function 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg(std::basic_istream<_CharT, _Traits>::pos_type)':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ')' before 'do'
/usr/include/c++/7/bits/istream.tcc: In member function 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg(std::basic_istream<_CharT, _Traits>::off_type, std::ios_base::seekdir)':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ')' before 'do'
/usr/include/c++/7/bits/regex.tcc: In member function 'int std::__cxx11::regex_traits< <template-parameter-1-1> >::value(_Ch_type, int) const':
graderlib.c:8:23: error: expected unqualified-id before 'do'
 #define fail(s, x...) do { \
                       ^
graderlib.c:8:23: error: expected ';' before 'do'
In file included from /usr/include/c++/7/bits/regex.h:2802:0,
                 from /usr/include/c++/7/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from cave.cpp:2:
/usr/include/c++/7/bits/regex.tcc:354:26: error: expected ';' before '?' token
       return __is.fail() ? -1 : __v;
                          ^
/usr/include/c++/7/bits/regex.tcc:354:26: error: expected primary-expression before '?' token