QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#674432 | #5426. Drain the Water Tank | heyuhao | WA | 1ms | 3652kb | C++20 | 1.2kb | 2024-10-25 15:43:47 | 2024-10-25 15:43:48 |
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||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]==1&&pos[(i+1)%n]==0)
{
ans++;
}
if(pos[i]==MAX&&pos[(i+1)%n]==0)
{
ans++;
}
if(pos[i]==1&&pos[(i+1)%n]==MAX)
{
ans++;
}
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3644kb
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: 3652kb
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: 3632kb
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: 3596kb
input:
6 0 0 2 0 1 1 4 1 5 0 3 4
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'