QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#632818 | #5426. Drain the Water Tank | CSQ# | WA | 1ms | 3604kb | C++17 | 979b | 2024-10-12 14:00:19 | 2024-10-12 14:00:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i < b;i++)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x.size())
typedef long long int ll;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
#define fi first
#define se second
ll dot(pii a,pii b){
return a.fi*b.fi + a.se * b.se;
}
ll cross(pii a,pii b){
return a.fi * b.se - a.se*b.fi;
}
int main()
{
int n;
cin>>n;
vector<pii>a(n);
int ans = 0;
for(int i=0;i<n;i++)cin>>a[i].fi>>a[i].se;
for(int i=0;i<n;i++){
pii b = a[(i+n-1)%n];
pii c = a[(i+1)%n];
if(b.se > a[i].se && c.se > a[i].se){
//cout<<i<<'\n';
if(dot({a[i].fi-b.fi,a[i].se-b.se},{c.fi-b.fi,c.se-b.se}) >= 0)ans++;
}
if(b.se > a[i].se && c.se == a[i].se){
if(dot({a[i].fi-b.fi,a[i].se-b.se},{c.fi-b.fi,c.se-b.se}) >= 0){
int j = (i+1)%n;
while(a[j].se == a[i].se){
j++;
j%n;
}
if(a[j].se > a[i].se)ans++;
}
}
}
cout<<ans<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
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: 1ms
memory: 3540kb
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: 3508kb
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: 3508kb
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'