제출 #712787

#제출 시각아이디문제언어결과실행 시간메모리
712787Marslai24콤보 (IOI18_combo)C++17
0 / 100
1 ms208 KiB
#include <bits/stdc++.h>
using namespace std;
//#define int long long // a.k.a. TLE creator
#define all(x) x.begin(), x.end()
template<class A, class B> istream& operator >>(istream &o, pair<A, B> &x){return o >> x.first >> x.second;}
template<class A, class B> ostream& operator <<(ostream &o, pair<A, B> &x){return o << x.first << ' ' << x.second << ' ';}
void setIO(){ios::sync_with_stdio(false); cin.tie(0);}
const int INF = 2e18, MOD = 998244353, N = 1e6 + 1, K = __lg(N) + 2;

int press(string p);

string guess_sequence(int n){
    string chr[4]{"A", "B", "C", "D"};
    string ans;
    if(press(chr[0] + chr[1]) == 1){
        if(press(chr[1]) == 1)
            swap(chr[0], chr[1]);
    }else{
        if(press(chr[2]) == 1)
            swap(chr[0], chr[2]);
        else swap(chr[0], chr[3]);
    }
    ans += chr[0];
    for(int len = 1; len < n; len++){
        int cur = press(ans + chr[1] + ans + chr[2] + chr[1] + ans + chr[2] + chr[2] + ans + chr[2] + chr[3]);
        if(cur == ans.size() + 1)ans += chr[1];
        else if(cur == ans.size() + 2)ans += chr[2];
        else ans += chr[3];
    }
    return ans;
}

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

combo.cpp:8:17: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+18' to '2147483647' [-Woverflow]
    8 | const int INF = 2e18, MOD = 998244353, N = 1e6 + 1, K = __lg(N) + 2;
      |                 ^~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(cur == ans.size() + 1)ans += chr[1];
      |            ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         else if(cur == ans.size() + 2)ans += chr[2];
      |                 ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...