Submission #20884

# Submission time Handle Problem Language Result Execution time Memory
20884 2017-03-04T15:48:01 Z 14kg 동전 게임 (KOI15_coin) C++11
100 / 100
39 ms 1116 KB
#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

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 time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 3 ms 1116 KB Output is correct
4 Correct 26 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 19 ms 1116 KB Output is correct
4 Correct 19 ms 1116 KB Output is correct
5 Correct 36 ms 1116 KB Output is correct
6 Correct 39 ms 1116 KB Output is correct
7 Correct 23 ms 1116 KB Output is correct
8 Correct 39 ms 1116 KB Output is correct