Submission #131059

#TimeUsernameProblemLanguageResultExecution timeMemory
131059abra_stone곡선 자르기 (KOI17_cut)C++14
11 / 100
3 ms508 KiB
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #define N 1000005 #define F first #define S second using namespace std; typedef long long ll; ll n, sz, c, ans1, ans2, tx[N], ty[N]; vector<ll> x, sy, ey; vector<pair<ll, ll> > s; int main() { ll i, j; cin >> n >> tx[0] >> ty[0]; for (i = 1; i < n; i++) { scanf("%lld %lld", &tx[i], &ty[i]); if (ty[i - 1] * ty[i] < 0) { x.push_back(tx[i]); sy.push_back(ty[i - 1]); ey.push_back(ty[i]); } } sz = x.size(); for (i = 0; i < sz; i++) { x.push_back(x[i]); sy.push_back(sy[i]); ey.push_back(ey[i]); } for (i = 0; sy[i] > ey[i]; i++); for (j = 0; j < sz; j += 2) { if (x[i + j] < x[i + j + 1]) { s.push_back({x[i + j], 1}); s.push_back({x[i + j + 1], -1}); } else { s.push_back({x[i + j], -1}); s.push_back({x[i + j + 1], 1}); } } sort(s.begin(), s.end()); for (i = 0; i < s.size(); i++) { if (s[i].S == 1 && s[i + 1].S == -1) ans2++; c += s[i].S; if (c == 0) ans1++; } cout << ans1 << ' ' << ans2 << endl; return 0; }

Compilation message (stderr)

cut.cpp: In function 'int main()':
cut.cpp:43:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < s.size(); i++) {
              ~~^~~~~~~~~~
cut.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &tx[i], &ty[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...