QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#720965 | #5426. Drain the Water Tank | Repeater# | WA | 0ms | 3812kb | C++20 | 1.0kb | 2024-11-07 14:50:17 | 2024-11-07 14:50:17 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'