제출 #199753

#제출 시각아이디문제언어결과실행 시간메모리
199753detaomega콤보 (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
char used[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int N) {
	string ans;
	int Not;
	int tmp = 3;
	int val;
	for(int i=0; i<3; i++) {
		int val = press(ans + used[i]);
		if(val) {
			Not = i;
			ans += used[i];
			break;
		}
	}
	if(val == 0) {
		Not = 3;
		ans += 'Y';
		val = 1;
	}		
	vector<char> vt;
	for(int i=0; i<4; i++) {
		if(i == Not) continue;
		vt.push_back(used[i]);
	}
	for(int i=1; i<N; i++) {
		bool fg = 0;
		for(int j=0;j<vt.size()-1; j++) {
			int cmp = press(ans + vt[j]);
			if(cmp > val) {
				fg = 1;
				val++;
				ans+=vt[j];
				break;
			}
		}
		if(fg==0) {
			ans+=vt.back();
			val++;
		}
 	}
 	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int j=0;j<vt.size()-1; j++) {
      |               ~^~~~~~~~~~~~
combo.cpp:9:6: warning: unused variable 'tmp' [-Wunused-variable]
    9 |  int tmp = 3;
      |      ^~~
combo.cpp:19:2: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |  if(val == 0) {
      |  ^~
combo.cpp:26:3: warning: 'Not' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |   if(i == Not) continue;
      |   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...