QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736198 | #5426. Drain the Water Tank | QingTian | WA | 0ms | 3856kb | C++20 | 1.0kb | 2024-11-12 04:52:18 | 2024-11-12 04:52:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef double ld;
typedef long long ll;
struct p2{
ll x,y;
friend p2 operator+(p2 a,p2 b){return {a.x+b.x,a.y+b.y};}
friend p2 operator-(p2 a,p2 b){return {a.x-b.x,a.y-b.y};}
friend p2 operator*(ll a,p2 b){return {a*b.x,a*b.y};}
friend ll operator*(p2 a,p2 b){return a.x*b.x+a.y*b.y;}
friend ll operator^(p2 a,p2 b){return a.x*b.y-a.y*b.x;}
void rd(){cin>>x>>y;}
void db(){cout<<x<<' '<<y<<'\n';}
};
void solve(){
int n;cin>>n;
vector<p2> v(n);
for(int i=0;i<n;i++) v[i].rd();
int i=0,res=0;
while(v[(i-1+n)%n].y==v[i%n].y) i++;
for(int j=0;j<n;j++,i++){
int y1,y2,y3;
p2 a=v[i%n]-v[(i-1+n)%n];
y1=v[(i-1+n)%n].y;
y2=v[i%n].y;
while(v[i%n].y==v[(i+1)%n].y) i++,j++;
p2 b=v[(i+1)%n]-v[i%n];
y3=v[(i+1)%n].y;
if((a^b)>0 && y1>y2 && y3>y2){
cerr<<i%n<<'\n';
res++;
}else if(a.x==0 && b.x==0 && a.y<0 && b.y>0){
cerr<<i%n<<'\n';
res++;
}
}
cout<<res<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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: 3548kb
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: 3856kb
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: 3544kb
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'