QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692526#5426. Drain the Water TankSmHaInTWA 0ms3556kbC++201.4kb2024-10-31 14:39:452024-10-31 14:39:46

Judging History

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

  • [2024-10-31 14:39:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-10-31 14:39:45]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
#include<deque>
using namespace std;

#define MAXN 301000;
#define ll long long
#define lll unsigned long long
#define PA pair<ll,ll>
#define INF (ll)0x3f3f3f3f*(ll)1000000
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = 1e9+7;

struct node {
	int x, y;
};

void solve() {
	int n; cin >> n;
	vector<node>arr(2 * n);

	bool c = false;
	for (int i = 0; i < n; i++) {
		cin >> arr[i].x >> arr[i].y;
		arr[i + n] = arr[i];

		if (arr[i + n].y != arr[i - 1 + n].y)c = true;
	}

	if (!c) {
		cout << 0 << endl;
		return;
	}

	vector<bool>visit(n,false);
	int cnt = 0;
	for (int i = n; i < 2 * n; i++) {
		if (visit[i % n])continue;

		int l = i - 1, r = (i + 1) % (2 * n);
		while (arr[l].y == arr[i].y)l--;
		while (arr[r].y == arr[i].y)r = (r + 1) % (2 * n);

		int p = r - 1;
		if (p < 0)p = 2 * n - 1;
		while (p != l) {
			visit[p % n] = true;
			p--;
			if (p < 0)p = 2 * n - 1;
		}

		if (arr[l].y > arr[i].y && arr[r].y > arr[i].y && arr[l].x<=arr[r].x) {
			cnt++;
		}

	}

	cout << cnt << endl;
}
int main() {
	IOS;
	int t = 1;// cin >> t;
	while (t--) {
		solve();
	}
}

详细

Test #1:

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

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: 3556kb

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: 3548kb

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: 3544kb

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'