Submission #148221

# Submission time Handle Problem Language Result Execution time Memory
148221 2019-08-31T17:54:08 Z FEDIKUS Combo (IOI18_combo) C++14
5 / 100
2 ms 280 KB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;

void uradi(string &upit,string s,char prvo){
    char niz[4];
    niz[0]='A';niz[1]='B';niz[2]='X';niz[3]='Y';
    bool bio=false;
    for(int i=0;i<4;i++){
        if(niz[i]==prvo) continue;
        if(bio){
            for(int j=0;j<4;j++){
                if(niz[j]!=prvo){
                    upit+=s;
                    upit+=niz[i];
                    upit+=niz[j];
                }
            }
            break;
        }else{
            bio=true;
            upit+=s;
            upit+=niz[i];
        }
    }
}
string guess_sequence(int n){
   // freopen("out.txt","a",stdout);
    string s="";
    char prvo;
    if(press("AB")>0){
        if(press("A")>0){
            s+='A';
            prvo='A';
        }else{
            s+='B';
            prvo='B';
        }
    }else{
        if(press("X")>0){
            s+='X';
            prvo='X';
        }else{
            s+='Y';
            prvo='Y';
        }
    }
  //  cout<<"evo:"<<s<<"\n";
    char niz[4];
    niz[0]='A';niz[1]='B';niz[2]='X';niz[3]='Y';
    for(int p=1;p<=n-2;p++){
        string upit="";
        uradi(upit,s,prvo);
        int nesto=press(upit);
        for(int i=0,j=0;i<4;i++){
                if(niz[i]==prvo) continue;
                if(j==0 && nesto==s.size()+1){
                    s+=niz[i];
                    break;
                }else if(j==1 && nesto==s.size()+2){
                    s+=niz[i];
                    break;
                }else if(j==2 && nesto==s.size()){
                    s+=niz[i];
                    break;
                }
                j++;
        }
   //     cout<<"evo:"<<s<<" "<<nesto<<"\n";
    }
    if(press(s+"A"+s+"B")>s.size()){
        if(press(s+"A")>s.size()){
            s+='A';
        }else{
            s+='B';
        }
    }else{
        if(press(s+"X")>s.size()){
            s+='X';
        }else{
            s+='Y';
        }
    }
    return s;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:57:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |                 if(j==0 && nesto==s.size()+1){
      |                            ~~~~~^~~~~~~~~~~~
combo.cpp:60:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |                 }else if(j==1 && nesto==s.size()+2){
      |                                  ~~~~~^~~~~~~~~~~~
combo.cpp:63:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |                 }else if(j==2 && nesto==s.size()){
      |                                  ~~~~~^~~~~~~~~~
combo.cpp:71:26: 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(s+"A"+s+"B")>s.size()){
      |        ~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:72:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         if(press(s+"A")>s.size()){
      |            ~~~~~~~~~~~~^~~~~~~~~
combo.cpp:78:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         if(press(s+"X")>s.size()){
      |            ~~~~~~~~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 2 ms 252 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 1 ms 200 KB Output is correct
17 Correct 1 ms 280 KB Output is correct
18 Correct 1 ms 200 KB Output is correct
19 Correct 1 ms 200 KB Output is correct
20 Correct 1 ms 268 KB Output is correct
21 Correct 1 ms 200 KB Output is correct
22 Correct 1 ms 200 KB Output is correct
23 Correct 1 ms 200 KB Output is correct
24 Correct 1 ms 200 KB Output is correct
25 Correct 1 ms 200 KB Output is correct
26 Correct 1 ms 200 KB Output is correct
27 Correct 1 ms 200 KB Output is correct
28 Correct 1 ms 200 KB Output is correct
29 Correct 1 ms 200 KB Output is correct
30 Correct 2 ms 200 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 2 ms 200 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 1 ms 200 KB Output is correct
35 Correct 1 ms 200 KB Output is correct
36 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -