Submission #107011

#TimeUsernameProblemLanguageResultExecution timeMemory
107011piri007곡선 자르기 (KOI17_cut)C++14
0 / 100
3 ms384 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...