답안 #257677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257677 2020-08-04T14:28:25 Z arnold518 Colors (BOI20_colors) C++14
0 / 100
0 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll N;

int query(ll x)
{
	printf("? %d\n", x);
	fflush(stdout);
	ll t;
	scanf("%lld", &t);
	return t;
}

void answer(ll x)
{
	printf("= %lld\n", x);
	fflush(stdout);
	exit(0);
}

int main()
{
	ll i, j;

	scanf("%lld", &N);
	vector<ll> V, V2;
	for(i=1; i<=N; i++) V.push_back(i);

	int l=0, r=V.size()-1;
	while(1)
	{
		if(l>r) break;
		V2.push_back(V[l++]);
		if(l>r) break;
		V2.push_back(V[r--]);
	}
	reverse(V2.begin(), V2.end());
	query(V2[0]);
	for(i=1; i<V2.size(); i++) if(query(V2[i])) break;
	answer(V2[i]-V2[i-1]);
}

Compilation message

Colors.cpp: In function 'int query(ll)':
Colors.cpp:12:20: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll {aka long long int}' [-Wformat=]
  printf("? %d\n", x);
                    ^
Colors.cpp: In function 'int main()':
Colors.cpp:44:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=1; i<V2.size(); i++) if(query(V2[i])) break;
           ~^~~~~~~~~~
Colors.cpp:28:8: warning: unused variable 'j' [-Wunused-variable]
  ll i, j;
        ^
Colors.cpp: In function 'int query(ll)':
Colors.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &t);
  ~~~~~^~~~~~~~~~~~
Colors.cpp: In function 'int main()':
Colors.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N);
  ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to -4, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to -4, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to -4, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to -4, violates the range [1, 7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Integer parameter [name=k] equals to -4, violates the range [1, 7]
2 Halted 0 ms 0 KB -