QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662063#5426. Drain the Water Tank1ockhartWA 0ms3804kbC++20792b2024-10-20 20:24:122024-10-20 20:24:36

Judging History

你现在查看的是最新测评结果

  • [2024-10-20 20:24:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-10-20 20:24:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
void solve() {
	int n;
	cin >> n;
	vector<pii> a;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a.push_back({ x,y });
	}
	for (int i = 0; i < n; i++)
		a.push_back(a[i]);
	int ans = 0;
	int f = 0;
	int p = n;
	for (int i = 1; i <= 2*n-1;i++) {
		if (i == p + n)
			break;
		if (a[i - 1].first <= a[i].first) {
			if (f && a[i - 1].second < a[i].second)	{
				f = 0, ans++;
				p = min(p, i);
			}
			if (a[i - 1].second > a[i].second)
				f = 1;
		}
		else
			f = 0;
	}
	cout << ans << '\n';
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

input:

6
0 0
1 1
2 1
3 0
3 2
0 2

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

8
4 4
0 4
0 2
1 2
2 2
2 0
3 0
4 0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

7
1 0
3 4
0 3
1 2
2 3
1 1
0 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3804kb

input:

6
0 0
2 0
1 1
4 1
5 0
3 4

output:

0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'