Submission #677494

#TimeUsernameProblemLanguageResultExecution timeMemory
677494hello_there_123Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include "combo.h" using namespace std; string arr[4]={"A","B","X","Y"}; set<string>st; int press(string s); string guess_sequence(int N){ if(N==1){ for(int i=0;i<4;i++){ if(press(arr[i]) == 1) return arr[i]; } } string ans = ""; string start = ""; st.insert("A"); st.insert("B"); st.insert("X"); st.insert("Y"); for(int i=0;i<4;i++){ string tr = ""; for(int j=0;j<4;j++){ tr = tr+arr[i]+arr[j]; } if(press(tr) == 2){ start = arr[i]; break; } } } if(start == "") start = "Y"; st.erase(start); vector<string>v; for(auto string:st) v.push_back(string); ans+=start; assert(ans.length() == 1); for(int i=0;i<N-2;i++){ string tr = ""; tr+=ans; tr+=v[0]; tr+=ans; tr+=v[1]; tr+=v[0]; tr+=ans; tr+=v[1]; tr+=v[1]; tr+=ans; tr+=v[1]; tr+=v[2]; if(press(tr) == ans.length()){ ans+=v[2]; } else if(press(tr) == ans.length()+1){ ans+=v[0]; } else ans+=v[1]; } if(press(ans+v[0]) == N) return ans+v[0]; if(press(ans+v[1]) == N) return ans+v[1]; if(press(ans+v[2])==N) return ans+v[2]; assert(1); }

Compilation message (stderr)

combo.cpp:30:2: error: expected unqualified-id before 'if'
   30 |  if(start == "") start = "Y";
      |  ^~
combo.cpp:31:2: error: 'st' does not name a type
   31 |  st.erase(start);
      |  ^~
combo.cpp:33:2: error: expected unqualified-id before 'for'
   33 |  for(auto string:st) v.push_back(string);
      |  ^~~
combo.cpp:34:2: error: 'ans' does not name a type; did you mean 'abs'?
   34 |  ans+=start;
      |  ^~~
      |  abs
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp:35:4: error: expected unqualified-id before 'static_cast'
   35 |    assert(ans.length() == 1);
      |    ^~~~~~
combo.cpp:35:4: error: expected ')' before 'static_cast'
combo.cpp:36:2: error: expected unqualified-id before 'for'
   36 |  for(int i=0;i<N-2;i++){
      |  ^~~
combo.cpp:36:14: error: 'i' does not name a type
   36 |  for(int i=0;i<N-2;i++){
      |              ^
combo.cpp:36:20: error: 'i' does not name a type
   36 |  for(int i=0;i<N-2;i++){
      |                    ^
combo.cpp:58:2: error: expected unqualified-id before 'if'
   58 |  if(press(ans+v[0]) == N) return ans+v[0];
      |  ^~
combo.cpp:59:2: error: expected unqualified-id before 'if'
   59 |  if(press(ans+v[1]) == N) return ans+v[1];
      |  ^~
combo.cpp:60:2: error: expected unqualified-id before 'if'
   60 |  if(press(ans+v[2])==N) return ans+v[2];
      |  ^~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp:61:4: error: expected unqualified-id before 'static_cast'
   61 |    assert(1);
      |    ^~~~~~
combo.cpp:61:4: error: expected ')' before 'static_cast'
combo.cpp:63:1: error: expected declaration before '}' token
   63 | }
      | ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:15: warning: control reaches end of non-void function [-Wreturn-type]
   13 |  string ans = "";
      |               ^~