#line 1 "code.cpp"
#include "combo.h"
#line 2 "library/template/template.hpp"
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define overload4(a,b,c,d,e,...) e
#define overload3(a,b,c,d,...) d
#define rep1(a) for(ll i=0;i<(ll)(a);i++)
#define rep2(i,a) for(ll i=0;i<(ll)(a);i++)
#define rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep4(i,a,b,c) for(ll i=(ll)(a);i<(ll)(b);i+=(ll)(c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(a) for(ll i=(ll)(a)-1;i>=0;i--)
#define rrep2(i,a) for(ll i=(ll)(a)-1;i>=0;i--)
#define rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) overload3(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define fore(...) for (auto&& __VA_ARGS__)
#define all1(i) begin(i),end(i)
#define all2(i,a) begin(i),begin(i)+a
#define all3(i,a,b) begin(i)+a,begin(i)+b
#define all(...) overload3(__VA_ARGS__,all3,all2,all1)(__VA_ARGS__)
#define rall(n) (n).rbegin(),(n).rend()
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define END(...) {print(__VA_ARGS__);return;}
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using vl=vector<ll>;
using vi=vector<int>;
using vs=vector<string>;
using vc=vector<char>;
using vvl=vector<vl>;
using pi=pair<int,int>;
using pl=pair<ll,ll>;
using vvc=vector<vc>;
using vd=vector<double>;
using vp=vector<pl>;
using vb=vector<bool>;
constexpr int dx[8]={1,0,-1,0,1,-1,-1,1};
constexpr int dy[8]={0,1,0,-1,1,1,-1,-1};
constexpr ll MOD=1000000007;
constexpr ll mod=998244353;
constexpr ld EPS=1e-8;
constexpr ld PI=3.1415926535897932384626;
template<typename T,typename U>
ostream &operator<<(ostream&os,const pair<T,U>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T,typename U>
istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<typename T>
ostream &operator<<(ostream&os,const vector<T>&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?" ":"");}return os;}
template<typename T>
istream &operator>>(istream&is,vector<T>&v){for(T &in:v){is>>in;}return is;}
void scan(){}
template<class Head,class... Tail>
void scan(Head&head,Tail&... tail){cin>>head;scan(tail...);}
template<class T>
void print(const T &t){cout<<t<<'\n';}
template<class Head, class... Tail>
void print(const Head &head, const Tail &... tail){cout<<head<<' ';print(tail...);}
template<class... T>
void fin(const T &... a){print(a...);exit(0);}
template<typename T,typename U>
inline bool chmax(T&a,U b){return a<b&&(a=b,true);}
template<typename T,typename U>
inline bool chmin(T&a,U b){return a>b&&(a=b,true);}
template<typename T>
class infinity{
public:
static constexpr T MAX=numeric_limits<T>::max();
static constexpr T MIN=numeric_limits<T>::min();
static constexpr T value=numeric_limits<T>::max()/2;
static constexpr T mvalue=numeric_limits<T>::min()/2;
};
#if __cplusplus <= 201402L
template<class T>constexpr T infinity<T>::value;
template<class T>constexpr T infinity<T>::mvalue;
template<class T>constexpr T infinity<T>::MAX;
template<class T>constexpr T infinity<T>::MIN;
#endif
template<typename T>constexpr T INF=infinity<T>::value;
constexpr long long inf=INF<ll>;
inline int popcnt(ull x){
#if __cplusplus>=202002L
return popcount(x);
#endif
x=(x&0x5555555555555555)+((x>>1)&0x5555555555555555);x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333);x=(x&0x0f0f0f0f0f0f0f0f)+((x>>4)&0x0f0f0f0f0f0f0f0f);x=(x&0x00ff00ff00ff00ff)+((x>>8)&0x00ff00ff00ff00ff);x=(x&0x0000ffff0000ffff)+((x>>16)&0x0000ffff0000ffff);return (x&0x00000000ffffffff)+((x>>32)&0x00000000ffffffff);
}
template<typename T,typename=void>
struct is_specialize:false_type{};
template<typename T>
struct is_specialize<T,typename conditional<false,typename T::iterator, void>::type>:true_type{};
template<typename T>
struct is_specialize<T,typename conditional<false,decltype(T::first),void>::type>:true_type{};
template<typename T>
struct is_specialize<T,enable_if_t<is_integral<T>::value,void>>:true_type{};
void dump(const char&t){cerr<<t;}
void dump(const string&t){cerr<<t;}
void dump(const bool&t){cerr<<(t?"true":"false");}
template <typename T,enable_if_t<!is_specialize<T>::value,nullptr_t> =nullptr>
void dump(const T&t){cerr<<t;}
template<typename T>
void dump(const T&t,enable_if_t<is_integral<T>::value>* =nullptr){string tmp;if(t==infinity<T>::value||t==infinity<T>::MAX)tmp="inf";if(is_signed<T>::value&&(t==infinity<T>::mvalue||t==infinity<T>::MIN))tmp="-inf";if(tmp.empty())tmp=to_string(t);cerr<<tmp;}
template<typename T,typename U>
void dump(const pair<T,U>&);
template<typename T>
void dump(const T&t,enable_if_t<!is_void<typename T::iterator>::value>* =nullptr){cerr<<"{";for(auto it=t.begin();it!=t.end();){dump(*it);cerr<<(++it==t.end()?"":",");}cerr<<"}";}
template<typename T,typename U>
void dump(const pair<T,U>&t){cerr<<"(";dump(t.first);cerr<<",";dump(t.second);cerr<<")";}
void trace(){cerr<<endl;}
template<typename Head,typename... Tail>
void trace(Head&&head,Tail&&... tail){dump(head);if(sizeof...(tail))cerr<<",";trace(forward<Tail>(tail)...);}
#ifdef ONLINE_JUDGE
#define debug(...) (void(0))
#else
#define debug(...) do{cerr<<#__VA_ARGS__<<"=";trace(__VA_ARGS__);}while(0)
#endif
struct IOSetup{IOSetup(){cin.tie(nullptr);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(12);cerr<<fixed<<setprecision(12);}};
template<class F>struct REC{F f;REC(F&&f_):f(std::forward<F>(f_)){}template<class...Args>auto operator()(Args&&...args)const{return f(*this, std::forward<Args>(args)...);}};
/**
* @brief Template(テンプレート)
*/
#line 3 "code.cpp"
string guess_sequence(int n){
string ans;
vector<string>cand{"A","B","X","Y"};
int ab=press("AB");
if(ab>0){
int a=press("A");
if(a)ans="A",cand.erase(find(all(cand),"A"));
else ans="B",cand.erase(find(all(cand),"B"));
}
else{
int x=press("X");
if(x)ans="X",cand.erase(find(all(cand),"X"));
else ans="Y",cand.erase(find(all(cand),"Y"));
}
if(n==1)return ans;
rep(i,1,n-1){
string tmp=ans+cand[0]+ans+cand[1]+cand[0]+ans+cand[1]+cand[1]+ans+cand[1]+cand[2];
int len=press(tmp);
if(len==i+2)ans+=cand[1];
else if(len==i+1)ans+=cand[0];
else ans+=cand[2];
}
if(press(ans+cand[0])==n)ans+=cand[0];
else if(press(ans+cand[1])==n)ans+=cand[1];
else ans+=cand[2];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
0 ms |
208 KB |
Output is correct |
17 |
Correct |
0 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
0 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
1 ms |
208 KB |
Output is correct |
27 |
Correct |
0 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
0 ms |
208 KB |
Output is correct |
30 |
Correct |
1 ms |
208 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
0 ms |
208 KB |
Output is correct |
35 |
Correct |
0 ms |
208 KB |
Output is correct |
36 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
28 ms |
356 KB |
Output is correct |
18 |
Correct |
20 ms |
396 KB |
Output is correct |
19 |
Correct |
28 ms |
456 KB |
Output is correct |
20 |
Correct |
28 ms |
408 KB |
Output is correct |
21 |
Correct |
19 ms |
376 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
1 ms |
208 KB |
Output is correct |
27 |
Correct |
2 ms |
208 KB |
Output is correct |
28 |
Correct |
2 ms |
208 KB |
Output is correct |
29 |
Correct |
2 ms |
208 KB |
Output is correct |
30 |
Correct |
2 ms |
208 KB |
Output is correct |
31 |
Correct |
2 ms |
208 KB |
Output is correct |
32 |
Correct |
21 ms |
440 KB |
Output is correct |
33 |
Correct |
26 ms |
452 KB |
Output is correct |
34 |
Correct |
12 ms |
352 KB |
Output is correct |
35 |
Correct |
29 ms |
348 KB |
Output is correct |
36 |
Correct |
24 ms |
352 KB |
Output is correct |
37 |
Correct |
24 ms |
352 KB |
Output is correct |
38 |
Correct |
23 ms |
408 KB |
Output is correct |
39 |
Correct |
25 ms |
460 KB |
Output is correct |
40 |
Correct |
22 ms |
420 KB |
Output is correct |
41 |
Correct |
22 ms |
352 KB |
Output is correct |
42 |
Correct |
25 ms |
352 KB |
Output is correct |
43 |
Correct |
19 ms |
356 KB |
Output is correct |
44 |
Correct |
26 ms |
356 KB |
Output is correct |
45 |
Correct |
22 ms |
372 KB |
Output is correct |
46 |
Correct |
25 ms |
480 KB |
Output is correct |
47 |
Correct |
24 ms |
460 KB |
Output is correct |
48 |
Correct |
22 ms |
348 KB |
Output is correct |
49 |
Correct |
16 ms |
356 KB |
Output is correct |
50 |
Correct |
21 ms |
352 KB |
Output is correct |
51 |
Correct |
17 ms |
460 KB |
Output is correct |
52 |
Correct |
23 ms |
348 KB |
Output is correct |
53 |
Correct |
28 ms |
384 KB |
Output is correct |
54 |
Correct |
22 ms |
352 KB |
Output is correct |
55 |
Correct |
30 ms |
360 KB |
Output is correct |
56 |
Correct |
24 ms |
472 KB |
Output is correct |
57 |
Correct |
23 ms |
348 KB |
Output is correct |
58 |
Correct |
21 ms |
412 KB |
Output is correct |
59 |
Correct |
27 ms |
368 KB |
Output is correct |
60 |
Correct |
30 ms |
356 KB |
Output is correct |
61 |
Correct |
29 ms |
428 KB |
Output is correct |
62 |
Correct |
23 ms |
412 KB |
Output is correct |
63 |
Correct |
24 ms |
456 KB |
Output is correct |
64 |
Correct |
26 ms |
356 KB |
Output is correct |
65 |
Correct |
26 ms |
444 KB |
Output is correct |
66 |
Correct |
21 ms |
368 KB |
Output is correct |
67 |
Correct |
25 ms |
348 KB |
Output is correct |
68 |
Correct |
26 ms |
392 KB |
Output is correct |
69 |
Correct |
23 ms |
420 KB |
Output is correct |
70 |
Correct |
15 ms |
368 KB |
Output is correct |
71 |
Correct |
17 ms |
444 KB |
Output is correct |
72 |
Correct |
21 ms |
380 KB |
Output is correct |
73 |
Correct |
26 ms |
380 KB |
Output is correct |
74 |
Correct |
23 ms |
352 KB |
Output is correct |
75 |
Correct |
26 ms |
348 KB |
Output is correct |
76 |
Correct |
26 ms |
352 KB |
Output is correct |
77 |
Correct |
15 ms |
476 KB |
Output is correct |
78 |
Correct |
1 ms |
208 KB |
Output is correct |
79 |
Correct |
1 ms |
208 KB |
Output is correct |
80 |
Correct |
1 ms |
208 KB |
Output is correct |
81 |
Correct |
1 ms |
208 KB |
Output is correct |
82 |
Correct |
0 ms |
208 KB |
Output is correct |
83 |
Correct |
1 ms |
208 KB |
Output is correct |
84 |
Correct |
1 ms |
208 KB |
Output is correct |
85 |
Correct |
1 ms |
208 KB |
Output is correct |
86 |
Correct |
1 ms |
208 KB |
Output is correct |
87 |
Correct |
1 ms |
208 KB |
Output is correct |
88 |
Correct |
1 ms |
208 KB |
Output is correct |
89 |
Correct |
0 ms |
208 KB |
Output is correct |
90 |
Correct |
1 ms |
208 KB |
Output is correct |
91 |
Correct |
1 ms |
208 KB |
Output is correct |
92 |
Correct |
1 ms |
208 KB |
Output is correct |
93 |
Correct |
1 ms |
208 KB |
Output is correct |
94 |
Correct |
1 ms |
208 KB |
Output is correct |
95 |
Correct |
1 ms |
208 KB |
Output is correct |
96 |
Correct |
1 ms |
208 KB |
Output is correct |
97 |
Correct |
1 ms |
208 KB |
Output is correct |
98 |
Correct |
1 ms |
208 KB |
Output is correct |
99 |
Correct |
1 ms |
208 KB |
Output is correct |
100 |
Correct |
1 ms |
208 KB |
Output is correct |
101 |
Correct |
1 ms |
208 KB |
Output is correct |
102 |
Correct |
1 ms |
296 KB |
Output is correct |
103 |
Correct |
1 ms |
288 KB |
Output is correct |
104 |
Correct |
1 ms |
208 KB |
Output is correct |
105 |
Correct |
1 ms |
208 KB |
Output is correct |
106 |
Correct |
1 ms |
208 KB |
Output is correct |
107 |
Correct |
1 ms |
208 KB |
Output is correct |
108 |
Correct |
1 ms |
208 KB |
Output is correct |
109 |
Correct |
1 ms |
208 KB |
Output is correct |
110 |
Correct |
0 ms |
208 KB |
Output is correct |
111 |
Correct |
1 ms |
208 KB |
Output is correct |
112 |
Correct |
1 ms |
208 KB |
Output is correct |
113 |
Correct |
0 ms |
208 KB |
Output is correct |
114 |
Correct |
1 ms |
208 KB |
Output is correct |
115 |
Correct |
1 ms |
208 KB |
Output is correct |
116 |
Correct |
1 ms |
208 KB |
Output is correct |
117 |
Correct |
1 ms |
208 KB |
Output is correct |
118 |
Correct |
1 ms |
208 KB |
Output is correct |
119 |
Correct |
1 ms |
208 KB |
Output is correct |
120 |
Correct |
1 ms |
208 KB |
Output is correct |
121 |
Correct |
1 ms |
208 KB |
Output is correct |
122 |
Correct |
1 ms |
208 KB |
Output is correct |
123 |
Correct |
1 ms |
208 KB |
Output is correct |