Submission #20884

#TimeUsernameProblemLanguageResultExecution timeMemory
2088414kg동전 게임 (KOI15_coin)C++11
100 / 100
39 ms1116 KiB
#include <stdio.h>
#define max2(x,y) (x>y?x:y)

int n;

bool f(int x, int y, int mx) {
	int turn = n - max2(x, y);
	
	if (x + turn - mx < y) return false;
	if (y + turn + mx < x) return false;
	return true;
}
int main() {
	int k, x, y;
	bool check;

	scanf("%d %d", &n, &k);
	while (k--) {
		scanf("%d %d", &x, &y), check = false;
		if (x > 0 && f(x - 1, y, 0)) check = true;
		if (y > 0 && f(x, y - 1, 1)) check = true;
		if (x + y == 0) check = true;
		printf("%d\n", check);
	}
}

Compilation message (stderr)

coin.cpp: In function 'int main()':
coin.cpp:17:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
                        ^
coin.cpp:19:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x, &y), check = false;
                                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...