제출 #486430

#제출 시각아이디문제언어결과실행 시간메모리
486430ssenseCombo (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long  ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
//#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
/*
	
 */
 
string guess_sequence(int n)
{
	string s;
	vector<char> a(4);
	a[0] = 'A'; a[1] = 'B'; a[2] = 'X'; a[3] = 'Y';
	s.pb(a[0]); s.pb(a[1]);
	int exclude = 0;
	int k = press(s);
	if(k >= 1)
	{
		s.pop_back();
		k = press(s);
		if(k == 0)
		{
			s.pop_back();
			s.pb(a[1]);
			exclude = 1;
		}
	}
	else
	{
		s.pop_back();s.pop_back();
		s.pb(a[2]);
		k = press(s);
		exclude = 2;
		if(k == 0)
		{
			s.pop_back();
			s.pb(a[3]);
			exclude = 3;
		}
	}
	int one = 0, two = 0, three = 0;
	if(exclude == one)
	{
		one++;
	}
	two = one+1;
	if(two == exclude)
	{
		two++;
	}
	three = two+1;
	if(three == exclude)
	{
		three++;
	}
	for(int i = 0; i < n-2; i++)
	{
		string now = s+a[one]+a[one]+s+a[one]+a[two]+s+a[one]+a[three]+s+a[two];
		k = press(now);
		if(k == s.size()+2)
		{
			s.pb(a[one]);
		}
		if(k == s.size()+1)
		{
			s.pb(a[two]);
		}
		if(k == s.size())
		{
			s.pb(a[three]);
		}
	}
	s.pb(a[0]); s.pb(a[1]);
	k = press(s);
	if(k >= s.size()-1)
	{
		s.pop_back();
		k = press(s);
		if(k == s.size()-1)
		{
			s.pop_back();
			s.pb(a[1]);
		}
	}
	else
	{
		s.pop_back();s.pop_back();
		s.pb(a[2]);
		k = press(s);
		if(k == s.size()-1)
		{
			s.pop_back();
			s.pb(a[3]);
		}
	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:77:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |   if(k == s.size()+2)
      |      ~~^~~~~~~~~~~~~
combo.cpp:81:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |   if(k == s.size()+1)
      |      ~~^~~~~~~~~~~~~
combo.cpp:85:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |   if(k == s.size())
      |      ~~^~~~~~~~~~~
combo.cpp:92:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |  if(k >= s.size()-1)
      |     ~~^~~~~~~~~~~~~
combo.cpp:96:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |   if(k == s.size()-1)
      |      ~~^~~~~~~~~~~~~
combo.cpp:107:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |   if(k == s.size()-1)
      |      ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...