QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674447 | #5426. Drain the Water Tank | heyuhao | WA | 0ms | 3728kb | C++20 | 1.3kb | 2024-10-25 15:50:06 | 2024-10-25 15:50:06 |
Judging History
answer
#include<bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int n;
const int MAX=1e9;
void solve()
{
cin>>n;
pair<int,int> a[2010];
for(int i=0;i<n;i++)
cin>>a[i].first>>a[i].second;
int pos[2010];
for(int i=0;i<n;i++)
{
int x1=a[i].first,y1=a[i].second;
int x2=a[(i+1)%n].first,y2=a[(i+1)%n].second;
if(x1==x2)
pos[i]=MAX;
else if(y1==y2)
pos[i]=-MAX;
else
{
if((y1-y2)*(x1-x2)>0)
pos[i]=1;
else
pos[i]=0;
}
}
int ans=0;
for(int i=0;i<n;i++)
{
if(pos[i]==0&&pos[(i+1)%n]==1)
{
ans++;
}
if(pos[i]==MAX&&pos[(i+1)%n]==1)
{
ans++;
}
if(pos[i]==0&&pos[(i+1)%n]==MAX)
{
ans++;
}
}
// for(int i=0;i<n;i++)
// {
// cout<<pos[i]<<" ";
// }
if(ans==0)
ans=1;
cout<<ans<<"\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
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: 3668kb
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: 3584kb
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: 3660kb
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'