제출 #961172

#제출 시각아이디문제언어결과실행 시간메모리
961172marinaluca콤보 (IOI18_combo)C++17
100 / 100
16 ms1976 KiB
#include <bits/stdc++.h>
/**#pragma GCC optimize ("O4")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")
**/
using namespace std;
/**#define int long long
#define ll long long
#define all(x) begin(x), end(x)
#define XX first
#define YY second**/
/**
#define cin fin
#define cout fout

ifstream cin ("");
ofstream cout ("");
**/
deque <char> buton = {'A', 'B', 'X', 'Y'};
int press (string s);
int N;
string ans;
int cnt = 0;
//int press (string c){s
    //cnt ++;
    //int maxi = 0;
    //for (int i = 0; i < c.size(); ++ i){
        //int ct = 0;
        //for (int j = i; j < c.size() && (j - i) < ans.size(); ++ j){
           // if (c[j] == c[j - i]{
                //ct ++;
               // maxi = max (maxi, ct);
           // }
            //else
               // break;
      //  }
    //}
    //return maxi;
//}

string guess_sequence (int N){
    string v;
    if (press("AB") > 0){
        if (press("A") > 0){
            v = "A";
            buton.erase(buton.begin());
        }
        else{
            v = "B";
            buton.erase(buton.begin() + 1);
        }
    }
    else{
        if (press("X") > 0){
            v = "X";
            buton.erase(buton.begin() + 2);
        }
        else{
            v = "Y";
            buton.erase(buton.begin() + 3);
        }
    }
    if (N == 1){
        return v;
    }
    for (int i = 2; i <= N - 1; ++ i){
        int sum = press (v + buton[1] + v + buton[2]  + buton[0] + v + buton[2] + buton[1] + v + buton[2] + buton[2]);
        v += buton[sum - v.size()];
    }
    if (press (v+ buton[0] + v + buton[1]) > v.size()){
        if (press (v + buton[0]) > v.size()){
            v += buton[0];
        }
        else{
            v += buton[1];
        }
    }
    else{
        v += buton[2];
    }
    return v;
} 
/**signed main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    return 0 ^ 0;
}**/

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:70:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     if (press (v+ buton[0] + v + buton[1]) > v.size()){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:71:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         if (press (v + buton[0]) > v.size()){
      |             ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...