Submission #378923

# Submission time Handle Problem Language Result Execution time Memory
378923 2021-03-17T07:37:47 Z jisnu Combo (IOI18_combo) C++11
30 / 100
46 ms 572 KB
#include "combo.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using ll=long long;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

void _print(vector<pii> x) {cerr<<"["; for(auto e:x) cerr<<"{"<<e.first<<","<<e.second<<"} ,"; cerr<<"]";}
template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}
void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"]";
    dbg(T...);
}
#define debug(...) cerr<<"[\""<<#__VA_ARGS__<<"\"]: [",dbg(__VA_ARGS__);

char a[4]={'A','B','X','Y'};
vector<char> ar;

std::string guess_sequence(int N) {
//    debug(N);
    string ans;
    for(int i=0;i<3;i++) {
        string temp; temp.push_back(a[i]);
        int res=press(temp);
        if(res==1) {
           ans+=a[i]; break;
        }
    }
    if(ans.empty()) ans.push_back(a[3]);

    for(int i=0;i<4;i++) {
        if(a[i]!=ans[0]) ar.push_back(a[i]);
    }
    bool past=false;
    vector<char> past_list;
    vector<string> guess_list;
    for(auto e:ar) {
        for(auto f:ar) {
            string temp; temp.push_back(e); temp.push_back(f);
            guess_list.push_back(temp);
        }
    }
//    debug(guess_list);
    for(int i=2;i<=N;i++) {
        int len=ans.size();
        if(past) {
            if(i==N) {
                string temp=ans; temp.push_back(past_list[0]);
                if(press(temp)==N) return temp;
                ans.push_back(past_list[1]);
                return ans;
            }
            else {
                string temp;
                for(int j=0;j<2;j++) {
                    temp+=ans; temp.push_back(past_list[0]);
                    temp.push_back(ar[j]);
                }
                int res=press(temp);
                if(res==len) {
                    ans.push_back(past_list[1]);
                    past=false;
                }
                else if(res==len+1) {
                    ans.push_back(past_list[0]);
                    ans.push_back(ar[2]); i++;
                    past=false;
                }
                else {
                    ans.push_back(past_list[0]);
                }
            }
        }
        else {
            if(i==N) {
                for(int j=0;j<2;j++) {
                    string temp=ans+ar[j];
                    if(press(temp)==N) return temp;
                }
                ans.push_back(ar[2]); return ans;
            }
            string temp;
            for(int j=0;j<4;j++) {
                temp+=ans+guess_list[j];
            }
            int res=press(temp);

            if(res==len) {
                ans.push_back(ar[2]);
            }
            else if(res==len+1) {
                ans.push_back(ar[1]);
            }
            else {
                temp="";
                for(int j=0;j<2;j++) {
                    temp+=ans+guess_list[j];
                }
                int res2=press(temp);
                if(res2==len) {
                    ans+=guess_list[3]; i++;
                }
                else if(res2==len+1) {
                    ans+=guess_list[2]; i++;
                }
                else {
                    ans.push_back(ar[0]);
                    past_list.clear();
                    past_list.push_back(ar[0]);
                    past_list.push_back(ar[1]);
                    past=true;
                }
            }
        }
    }
    return ans;
}
# 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 0 ms 200 KB Output is correct
4 Correct 0 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 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 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 256 KB Output is correct
16 Correct 1 ms 200 KB Output is correct
17 Correct 1 ms 200 KB Output is correct
18 Correct 1 ms 200 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 1 ms 276 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 1 ms 200 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
33 Correct 0 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 244 KB Output is correct
# 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 256 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 0 ms 200 KB Output is correct
12 Partially correct 1 ms 200 KB Output is partially correct
13 Partially correct 1 ms 200 KB Output is partially correct
14 Correct 1 ms 200 KB Output is correct
15 Partially correct 1 ms 200 KB Output is partially correct
16 Partially correct 0 ms 200 KB Output is partially correct
17 Partially correct 35 ms 572 KB Output is partially correct
18 Partially correct 30 ms 380 KB Output is partially correct
19 Partially correct 39 ms 448 KB Output is partially correct
20 Partially correct 40 ms 428 KB Output is partially correct
21 Partially correct 17 ms 388 KB Output is partially correct
22 Correct 1 ms 200 KB Output is correct
23 Partially correct 2 ms 256 KB Output is partially correct
24 Partially correct 1 ms 200 KB Output is partially correct
25 Partially correct 3 ms 200 KB Output is partially correct
26 Partially correct 2 ms 200 KB Output is partially correct
27 Partially correct 1 ms 296 KB Output is partially correct
28 Partially correct 2 ms 292 KB Output is partially correct
29 Partially correct 2 ms 296 KB Output is partially correct
30 Partially correct 3 ms 200 KB Output is partially correct
31 Partially correct 2 ms 308 KB Output is partially correct
32 Partially correct 39 ms 368 KB Output is partially correct
33 Partially correct 33 ms 368 KB Output is partially correct
34 Partially correct 18 ms 364 KB Output is partially correct
35 Partially correct 35 ms 372 KB Output is partially correct
36 Partially correct 25 ms 368 KB Output is partially correct
37 Partially correct 39 ms 464 KB Output is partially correct
38 Partially correct 36 ms 364 KB Output is partially correct
39 Partially correct 41 ms 464 KB Output is partially correct
40 Partially correct 24 ms 364 KB Output is partially correct
41 Partially correct 36 ms 384 KB Output is partially correct
42 Partially correct 32 ms 368 KB Output is partially correct
43 Partially correct 17 ms 364 KB Output is partially correct
44 Partially correct 18 ms 372 KB Output is partially correct
45 Partially correct 30 ms 400 KB Output is partially correct
46 Partially correct 26 ms 404 KB Output is partially correct
47 Partially correct 44 ms 368 KB Output is partially correct
48 Partially correct 38 ms 412 KB Output is partially correct
49 Partially correct 29 ms 456 KB Output is partially correct
50 Partially correct 27 ms 428 KB Output is partially correct
51 Partially correct 38 ms 368 KB Output is partially correct
52 Partially correct 20 ms 408 KB Output is partially correct
53 Partially correct 38 ms 452 KB Output is partially correct
54 Correct 32 ms 332 KB Output is correct
55 Correct 29 ms 324 KB Output is correct
56 Partially correct 25 ms 348 KB Output is partially correct
57 Partially correct 29 ms 424 KB Output is partially correct
58 Correct 22 ms 368 KB Output is correct
59 Correct 25 ms 368 KB Output is correct
60 Partially correct 34 ms 368 KB Output is partially correct
61 Partially correct 37 ms 472 KB Output is partially correct
62 Correct 38 ms 416 KB Output is correct
63 Correct 36 ms 504 KB Output is correct
64 Partially correct 35 ms 424 KB Output is partially correct
65 Partially correct 34 ms 492 KB Output is partially correct
66 Partially correct 46 ms 372 KB Output is partially correct
67 Partially correct 32 ms 484 KB Output is partially correct
68 Partially correct 32 ms 492 KB Output is partially correct
69 Partially correct 33 ms 440 KB Output is partially correct
70 Partially correct 25 ms 456 KB Output is partially correct
71 Partially correct 38 ms 452 KB Output is partially correct
72 Partially correct 22 ms 496 KB Output is partially correct
73 Partially correct 39 ms 392 KB Output is partially correct
74 Partially correct 45 ms 364 KB Output is partially correct
75 Partially correct 43 ms 364 KB Output is partially correct
76 Partially correct 36 ms 364 KB Output is partially correct
77 Partially correct 36 ms 424 KB Output is partially correct
78 Partially correct 1 ms 200 KB Output is partially correct
79 Partially correct 1 ms 200 KB Output is partially correct
80 Correct 1 ms 200 KB Output is correct
81 Partially correct 1 ms 200 KB Output is partially correct
82 Partially correct 1 ms 200 KB Output is partially correct
83 Partially correct 1 ms 200 KB Output is partially correct
84 Partially correct 1 ms 292 KB Output is partially correct
85 Partially correct 2 ms 200 KB Output is partially correct
86 Correct 1 ms 292 KB Output is correct
87 Partially correct 2 ms 200 KB Output is partially correct
88 Correct 1 ms 200 KB Output is correct
89 Correct 1 ms 200 KB Output is correct
90 Partially correct 1 ms 200 KB Output is partially correct
91 Partially correct 1 ms 200 KB Output is partially correct
92 Correct 1 ms 200 KB Output is correct
93 Correct 1 ms 200 KB Output is correct
94 Partially correct 1 ms 200 KB Output is partially correct
95 Partially correct 1 ms 200 KB Output is partially correct
96 Correct 1 ms 256 KB Output is correct
97 Correct 1 ms 296 KB Output is correct
98 Partially correct 1 ms 292 KB Output is partially correct
99 Partially correct 1 ms 292 KB Output is partially correct
100 Correct 1 ms 200 KB Output is correct
101 Correct 1 ms 200 KB Output is correct
102 Partially correct 1 ms 200 KB Output is partially correct
103 Partially correct 1 ms 284 KB Output is partially correct
104 Correct 1 ms 292 KB Output is correct
105 Correct 1 ms 288 KB Output is correct
106 Partially correct 2 ms 200 KB Output is partially correct
107 Partially correct 1 ms 200 KB Output is partially correct
108 Correct 1 ms 200 KB Output is correct
109 Correct 1 ms 256 KB Output is correct
110 Partially correct 0 ms 200 KB Output is partially correct
111 Partially correct 1 ms 200 KB Output is partially correct
112 Correct 1 ms 200 KB Output is correct
113 Correct 0 ms 200 KB Output is correct
114 Partially correct 1 ms 200 KB Output is partially correct
115 Partially correct 1 ms 200 KB Output is partially correct
116 Correct 1 ms 200 KB Output is correct
117 Partially correct 1 ms 200 KB Output is partially correct
118 Correct 1 ms 200 KB Output is correct
119 Partially correct 1 ms 200 KB Output is partially correct
120 Partially correct 1 ms 292 KB Output is partially correct
121 Partially correct 1 ms 200 KB Output is partially correct
122 Partially correct 2 ms 200 KB Output is partially correct
123 Partially correct 1 ms 200 KB Output is partially correct