Submission #131059

# Submission time Handle Problem Language Result Execution time Memory
131059 2019-07-16T12:16:33 Z abra_stone None (KOI17_cut) C++14
11 / 100
3 ms 508 KB
#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

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Incorrect 3 ms 508 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Incorrect 3 ms 508 KB Output isn't correct
19 Halted 0 ms 0 KB -