Submission #1185765

#TimeUsernameProblemLanguageResultExecution timeMemory
1185765Mamikonm1Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include<bits//stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string s; vector<pair<int,char>>x({{0,'A'},{0,'B'},{0,'X'},{0,'Y'}); set<string>st; int mx=0,cur; for(;;){ bool ok=0; for(char j:x){ s+=j.second; if(!st.count(s)){ cur=press(s); if(cur>mx){ mx=cur; ok=1; break; } st.insert(s); } s.pop_back(); } if(!ok or s.size()==N)break; } for(;s.size()!=N;){ bool ok=0; for(char j:x){ s=j.second+s; if(!st.count(s)){ cur=press(s); if(cur>mx){ mx=cur; ok=1; break; } st.insert(s); } reverse(begin(s),end(s)); s.pop_back(); reverse(begin(s),end(s)); } if(!ok)break; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:61: error: expected '}' before ')' token
    6 |     vector<pair<int,char>>x({{0,'A'},{0,'B'},{0,'X'},{0,'Y'});
      |                             ~                               ^
combo.cpp:11:20: error: cannot convert 'std::pair<int, char>' to 'char' in initialization
   11 |         for(char j:x){
      |                    ^
combo.cpp:12:18: error: request for member 'second' in 'j', which is of non-class type 'char'
   12 |             s+=j.second;
      |                  ^~~~~~
combo.cpp:28:20: error: cannot convert 'std::pair<int, char>' to 'char' in initialization
   28 |         for(char j:x){
      |                    ^
combo.cpp:29:17: error: request for member 'second' in 'j', which is of non-class type 'char'
   29 |             s=j.second+s;
      |                 ^~~~~~