QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720965#5426. Drain the Water TankRepeater#WA 0ms3812kbC++201.0kb2024-11-07 14:50:172024-11-07 14:50:17

Judging History

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

  • [2024-11-07 14:50:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-11-07 14:50:17]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

struct P{
	int x, y;

	P operator+(P p) { return {x + p.x, y + p.y};}
	P operator-(P p) { return {x - p.x, y - p.y};}

	int dot(P p){ return x * p.x + y * p.y; }
	int det(P p){ return x * p.y - y * p.x; }
};

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;

	vector<P> p(n);
	for(int i = 0; i < n; i++)
		cin >> p[i].x >> p[i].y;

	int s = 0;

	for(int i = 0; i < n; i++)
		if(p[i].y < p[s].y)
			s = i;

	int ans = 0, l = s, r = s;

	P cur = p[(r + 1) % n] - p[r];
	while(cur.y >= 0 || cur.x < 0){
		// cerr << r << " " << cur.x << " " << cur.y << "\n";
		r = (r + 1) % n;
		cur = p[(r + 1) % n] - p[r];
	}

	cur = p[(n + l - 1) % n] - p[l];
	while(l != r){
		while(l != r && (cur.y >= 0 || cur.x > 0)){
			// cerr << l << " " << cur.x << " " << cur.y << "\n";
			l = (n + l - 1) % n;
			cur = p[(n + l - 1) % n] - p[l];
		}
		if(l != r) 
			l = (n + l - 1) % n;
		ans++;
	}

	cout << ans;

	return 0;
}

详细

Test #1:

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

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

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

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

input:

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

output:

1

result:

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