Submission #131056

#TimeUsernameProblemLanguageResultExecution timeMemory
131056sean617곡선 자르기 (KOI17_cut)C++98
0 / 100
2 ms376 KiB
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #define N 1000005 #define F first #define S second using namespace std; int n, sz, st, m, cnt, s1, s2, x[N], y[N], a[N]; struct str { int c, z, num; } b[N]; bool comp(str p, str q) { return p.c < q.c; } int main() { int i, j; cin >> n; scanf ("%d %d", &x[0], &y[0]); sz = st = 1; for (i = 1; i < n; i++) { scanf ("%d %d", &x[i], &y[i]); if (y[i] > 0 && y[i - 1] < 0 || y[i] < 0 && y[i - 1] > 0) a[sz++] = x[i]; } if (y[0] > 0) { st = 0; a[0] = a[sz - 1]; sz--; } for (i = st, j = 1; i < sz; i += 2, j++) { if (a[i] > a[i + 1]) swap(a[i], a[i + 1]); b[m].c = a[i]; b[m + 1].c = a[i + 1]; b[m].z = 1; b[m + 1].z = 2; b[m].num = j; b[m + 1].num = j; m += 2; } sort(b, b + m, comp); for (i = 0; i < m; i++) { if (b[i].z == 1) { cnt++; if (cnt == 1) s1++; if (b[i + 1].z == 2 && b[i + 1].num == b[i].num) s2++; } else cnt--; } cout << s1 << " " << s2; return 0; }

Compilation message (stderr)

cut.cpp: In function 'int main()':
cut.cpp:26:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if (y[i] > 0 && y[i - 1] < 0 || y[i] < 0 && y[i - 1] > 0) a[sz++] = x[i];
       ~~~~~~~~~^~~~~~~~~~~~~~~
cut.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %d", &x[0], &y[0]);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
cut.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d %d", &x[i], &y[i]);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...