Submission #297159

#TimeUsernameProblemLanguageResultExecution timeMemory
297159shayan_pCombo (IOI18_combo)C++17
100 / 100
31 ms640 KiB
#include<bits/stdc++.h>
#include "combo.h"
     
#define sz(s) (int(s.size()))
#define PB push_back
     
using namespace std;
     
// A B X Y
string guess_sequence(int n){
    string ans;
    if(press("AB"))
	ans = press("A") ? "A" : "B";
    else
	ans = press("X") ? "X" : "Y";
    
    vector<string> c;
    for(string s : {"A", "B", "X", "Y"})
    	if(ans != s)
    	    c.PB(s);
    for(int i = 2; i < n; i++){
    	int coin = press(ans + c[0] + ans + c[1] + c[0] + ans + c[1] + c[1] + ans + c[1] + c[2]);
    	if(coin == sz(ans) + 1)
    	    ans+= c[0];
    	else if(coin == sz(ans) + 2)
    	    ans+= c[1];
    	else
    	    ans+= c[2];
    }
    if(n > 1){
    	if(press(ans + c[0]) == n)
    	    ans+= c[0];
    	else if(press(ans + c[1]) == n)
    	    ans+= c[1];
    	else
    	    ans+= c[2];
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...