QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#678094#5426. Drain the Water TankyimgWA 1ms3776kbC++20964b2024-10-26 14:01:212024-10-26 14:01:22

Judging History

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

  • [2024-10-26 14:01:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3776kb
  • [2024-10-26 14:01:21]
  • 提交

answer

#include<bits/stdc++.h>
#define nxt(x) (x + 1) % n
#define lst(x) (x - 1 + n) % n
using namespace std;

void work()
{
	int n;
	cin >> n;
	deque<pair<int, int>> a;
	for(int i = 0; i < n; ++i){
		int x, y; cin >> x >> y;
		a.push_back({x, y});
	}
	while(a[0].second <= a[1].second){
		a.push_back(a.front());
		a.pop_front();
	}
	int l = 0, r = 0, ans = 0;
	auto dec = [&](int c1, int c2, int c3){
		int x1 = a[c1].first, x2 = a[c2].first, x3 = a[c3].first;
		int y1 = a[c1].second, y2 = a[c2].second, y3 = a[c3].second;
		return (x1 - x2)*(y3 - y2) < (x3 - x2)*(y1 - y2);
	};
	for(int i = 0; i < n; ++i)
	{
		if(a[nxt(i)].second != a[i].second){
			r = i;
			if(a[lst(l)].second > a[l].second && a[nxt(r)].second > a[r].second && dec(lst(l), l, nxt(r))){
				ans++;
			}
			l = nxt(i);
		}
	}
	cout << ans << "\n";
} 
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
		work();
}

詳細信息

Test #1:

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

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

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: 1ms
memory: 3768kb

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: 0
Accepted
time: 0ms
memory: 3608kb

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

8
0 0
1 0
3 -1
3 0
1 1
4 1
5 0
3 4

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

5
0 0
170 0
140 30
60 30
0 70

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

5
0 0
170 0
140 30
60 30
0 100

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

5
0 0
1 2
1 5
0 2
0 1

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

3
0 0
100 0
0 100

output:

0

result:

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