Submission #849924

#TimeUsernameProblemLanguageResultExecution timeMemory
849924Andrijanikolic73Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
//#include <bits/stdc++.h>
//#include "combo.h"
//using namespace std;
#include "combo.h"

std::string guess_sequence(int N) {
    string pref="";
    char P[4]={'A','B','C','D'};
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            if(press(pref+P[j])==i+1){
                pref+=P[j];
                break;
            }
        }
    }
    return pref;
}
/*
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    char P[4]={'A','B','X','Y'};
    if(n==3){
        for(int i=0;i<n;i++){
            for(int j=0;j<4;j++){
                if(press(pref+P[j])==i+1){
                    pref+=P[j];
                    break;
                }
            }
        }
        guess_sequence(n);
    }
}*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:5: error: 'string' was not declared in this scope
    7 |     string pref="";
      |     ^~~~~~
combo.cpp:7:5: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:4:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from combo.h:3,
                 from combo.cpp:4:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
combo.cpp:9:19: error: 'n' was not declared in this scope
    9 |     for(int i=0;i<n;i++){
      |                   ^
combo.cpp:11:22: error: 'pref' was not declared in this scope
   11 |             if(press(pref+P[j])==i+1){
      |                      ^~~~
combo.cpp:17:12: error: 'pref' was not declared in this scope
   17 |     return pref;
      |            ^~~~