Submission #107011

# Submission time Handle Problem Language Result Execution time Memory
107011 2019-04-21T12:51:21 Z piri007 None (KOI17_cut) C++14
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

stack <int> s; //작동시 현재 갇혀있는가 안 갇혀있는가
priority_queue<pair<int, int>> q;//짝궁정하기

int main()
{
	int ban, ban2 = 0, fx, fy; //처음 y가 양수일 때의 반례를 해결해보자
	int n, x, y = 0, num[] = {0, 0};
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		if (ban2 && i + 1 == n) a = fx, b = fy;
		else scanf("%d %d", &a, &b);

		if (!y && b > 0)
			num[1] = 1, ban2 = 1, n++, fx = a, fy = b;

		if (y && b*y < 0)
		{
			q.emplace(-a, num[0]);
			ban = -a;

			if (!num[1]) num[1]++;
			else num[0]++, num[1] = 0;
		}
		x = a, y = b;
	}

	int res1 = 0, res2 = 0, before = -1; 

	while (!q.empty())
	{
		int mat = q.top().second;  //0부터 시작
		if (ban2 && q.top().first == ban) mat = 0;
		q.pop();

	//	printf("mate : %d, size : %d\n", mat, s.size());
		if (s.empty() || s.top() != mat) s.push(mat);
		else if (!s.empty()) s.pop();     //갇힘? 풀림?

		if (s.empty()) res1++;            //이 단계에서 풀렸으면 가장 밖
		if (mat == before) res2++;       //()모양일때 가장 안

		before = mat;
	}
	printf("%d %d", res1, res2);
}

Compilation message

cut.cpp: In function 'int main()':
cut.cpp:11:9: warning: variable 'x' set but not used [-Wunused-but-set-variable]
  int n, x, y = 0, num[] = {0, 0};
         ^
cut.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
cut.cpp:17:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   else scanf("%d %d", &a, &b);
        ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 256 KB Output is correct
15 Incorrect 2 ms 384 KB Output isn't correct