Submission #78569

# Submission time Handle Problem Language Result Execution time Memory
78569 2018-10-06T12:26:18 Z KLPP Combo (IOI18_combo) C++14
100 / 100
53 ms 608 KB
#include "combo.h"
#include<iostream>
 
using namespace std;
 
std::string guess_sequence(int N) {
	string s="";
	int p=press("AB");
	if(p>0){
		p=press("A");
		if(p>0){
			s+='A';
			while(s.length()<N-1){
				string h=s+"B";
				h+=s+"XB";
				h+=s+"XY";
				h+=s+"XX";
				int x=press(h);
				int y=s.length();
				if(x==y){
					s+='Y';
				}else if(x==y+1){
					s+='B';
				}else{
					s+='X';
				}
			}
          	if(N==1)return s;
			if(press(s+'X')>s.length()){
				s+='X';
			}
			else if(press(s+'B')>s.length()){
				s+='B';
			}else{
				s+='Y';
			}
			
			return s;
		}
		s+='B';
		while(s.length()<N-1){
			string h=s+"A";
			h+=s+"XA";
			h+=s+"XY";
			h+=s+"XX";
			int x=press(h);
			int y=s.length();
			if(x==y){
				s+='Y';
			}else if(x==y+1){
				s+='A';
			}else{
				s+='X';
			}
		}if(N==1)return s;
		if(press(s+'X')>s.length()){
			s+='X';
		}
		else if(press(s+'A')>s.length()){
			s+='A';
		}else{
			s+='Y';
		}
		return s;
	}
	p=press("X");
	if(p>0){
		s+='X';
		while(s.length()<N-1){
			string h=s+"A";
			h+=s+"BA";
			h+=s+"BY";
			h+=s+"BB";
			int x=press(h);
			int y=s.length();
			if(x==y){
				s+='Y';
			}else if(x==y+1){
				s+='A';
			}else{
				s+='B';
			}
		}if(N==1)return s;
		if(press(s+'B')>s.length()){
			s+='B';
		}
		else if(press(s+'A')>s.length()){
			s+='A';
		}else{
			s+='Y';
		}
		return s;
	}
	s+='Y';
	while(s.length()<N-1){
		string h=s+"A";
		h+=s+"BA";
		h+=s+"BX";
		h+=s+"BB";
		int x=press(h);
		int y=s.length();
		if(x==y){
			s+='X';
		}else if(x==y+1){
			s+='A';
		}else{
			s+='B';
		}
	}if(N==1)return s;
	if(press(s+'B')>s.length()){
		s+='B';
	}
	else if(press(s+'A')>s.length()){
		s+='A';
	}else{
		s+='X';
	}
	return s;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |    while(s.length()<N-1){
      |          ~~~~~~~~~~^~~~
combo.cpp:28:12: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |            if(N==1)return s;
      |            ^~
combo.cpp:29:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |    if(press(s+'X')>s.length()){
      |    ^~
combo.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    if(press(s+'X')>s.length()){
      |       ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    else if(press(s+'B')>s.length()){
      |            ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:41:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   while(s.length()<N-1){
      |         ~~~~~~~~~~^~~~
combo.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   if(press(s+'X')>s.length()){
      |      ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   else if(press(s+'A')>s.length()){
      |           ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:69:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |   while(s.length()<N-1){
      |         ~~~~~~~~~~^~~~
combo.cpp:84:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   if(press(s+'B')>s.length()){
      |      ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:87:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |   else if(press(s+'A')>s.length()){
      |           ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:95:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   95 |  while(s.length()<N-1){
      |        ~~~~~~~~~~^~~~
combo.cpp:110:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |  if(press(s+'B')>s.length()){
      |     ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:113:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |  else if(press(s+'A')>s.length()){
      |          ~~~~~~~~~~~~^~~~~~~~~~~
# 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 2 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 2 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 2 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 200 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 200 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 2 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 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 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 248 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 200 KB Output is correct
17 Correct 33 ms 384 KB Output is correct
18 Correct 38 ms 380 KB Output is correct
19 Correct 30 ms 492 KB Output is correct
20 Correct 30 ms 480 KB Output is correct
21 Correct 31 ms 372 KB Output is correct
22 Correct 1 ms 200 KB Output is correct
23 Correct 2 ms 200 KB Output is correct
24 Correct 2 ms 288 KB Output is correct
25 Correct 3 ms 200 KB Output is correct
26 Correct 2 ms 200 KB Output is correct
27 Correct 2 ms 292 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 3 ms 316 KB Output is correct
30 Correct 4 ms 320 KB Output is correct
31 Correct 4 ms 320 KB Output is correct
32 Correct 39 ms 452 KB Output is correct
33 Correct 38 ms 464 KB Output is correct
34 Correct 41 ms 488 KB Output is correct
35 Correct 34 ms 408 KB Output is correct
36 Correct 39 ms 604 KB Output is correct
37 Correct 24 ms 468 KB Output is correct
38 Correct 43 ms 452 KB Output is correct
39 Correct 33 ms 472 KB Output is correct
40 Correct 25 ms 384 KB Output is correct
41 Correct 23 ms 376 KB Output is correct
42 Correct 33 ms 380 KB Output is correct
43 Correct 24 ms 496 KB Output is correct
44 Correct 40 ms 380 KB Output is correct
45 Correct 40 ms 456 KB Output is correct
46 Correct 35 ms 380 KB Output is correct
47 Correct 44 ms 592 KB Output is correct
48 Correct 40 ms 380 KB Output is correct
49 Correct 39 ms 436 KB Output is correct
50 Correct 31 ms 380 KB Output is correct
51 Correct 38 ms 376 KB Output is correct
52 Correct 45 ms 380 KB Output is correct
53 Correct 34 ms 476 KB Output is correct
54 Correct 35 ms 608 KB Output is correct
55 Correct 36 ms 380 KB Output is correct
56 Correct 36 ms 380 KB Output is correct
57 Correct 44 ms 496 KB Output is correct
58 Correct 36 ms 444 KB Output is correct
59 Correct 30 ms 508 KB Output is correct
60 Correct 36 ms 384 KB Output is correct
61 Correct 35 ms 480 KB Output is correct
62 Correct 44 ms 408 KB Output is correct
63 Correct 53 ms 464 KB Output is correct
64 Correct 51 ms 520 KB Output is correct
65 Correct 43 ms 444 KB Output is correct
66 Correct 36 ms 380 KB Output is correct
67 Correct 51 ms 380 KB Output is correct
68 Correct 25 ms 380 KB Output is correct
69 Correct 34 ms 392 KB Output is correct
70 Correct 46 ms 476 KB Output is correct
71 Correct 39 ms 488 KB Output is correct
72 Correct 23 ms 484 KB Output is correct
73 Correct 39 ms 468 KB Output is correct
74 Correct 44 ms 452 KB Output is correct
75 Correct 52 ms 380 KB Output is correct
76 Correct 43 ms 432 KB Output is correct
77 Correct 38 ms 380 KB Output is correct
78 Correct 1 ms 200 KB Output is correct
79 Correct 1 ms 200 KB Output is correct
80 Correct 1 ms 200 KB Output is correct
81 Correct 1 ms 200 KB Output is correct
82 Correct 2 ms 200 KB Output is correct
83 Correct 1 ms 200 KB Output is correct
84 Correct 1 ms 200 KB Output is correct
85 Correct 2 ms 200 KB Output is correct
86 Correct 1 ms 200 KB Output is correct
87 Correct 2 ms 200 KB Output is correct
88 Correct 1 ms 200 KB Output is correct
89 Correct 1 ms 200 KB Output is correct
90 Correct 1 ms 200 KB Output is correct
91 Correct 2 ms 220 KB Output is correct
92 Correct 1 ms 256 KB Output is correct
93 Correct 2 ms 200 KB Output is correct
94 Correct 1 ms 288 KB Output is correct
95 Correct 1 ms 200 KB Output is correct
96 Correct 2 ms 292 KB Output is correct
97 Correct 2 ms 200 KB Output is correct
98 Correct 2 ms 200 KB Output is correct
99 Correct 3 ms 200 KB Output is correct
100 Correct 2 ms 292 KB Output is correct
101 Correct 1 ms 300 KB Output is correct
102 Correct 4 ms 288 KB Output is correct
103 Correct 2 ms 296 KB Output is correct
104 Correct 1 ms 200 KB Output is correct
105 Correct 2 ms 200 KB Output is correct
106 Correct 2 ms 200 KB Output is correct
107 Correct 2 ms 200 KB Output is correct
108 Correct 1 ms 200 KB Output is correct
109 Correct 1 ms 200 KB Output is correct
110 Correct 1 ms 200 KB Output is correct
111 Correct 1 ms 200 KB Output is correct
112 Correct 1 ms 224 KB Output is correct
113 Correct 2 ms 200 KB Output is correct
114 Correct 2 ms 200 KB Output is correct
115 Correct 2 ms 200 KB Output is correct
116 Correct 2 ms 200 KB Output is correct
117 Correct 1 ms 200 KB Output is correct
118 Correct 1 ms 200 KB Output is correct
119 Correct 1 ms 200 KB Output is correct
120 Correct 1 ms 200 KB Output is correct
121 Correct 2 ms 200 KB Output is correct
122 Correct 1 ms 292 KB Output is correct
123 Correct 2 ms 200 KB Output is correct