QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#671605 | #5426. Drain the Water Tank | hansue# | WA | 0ms | 3628kb | C++20 | 1.0kb | 2024-10-24 13:40:20 | 2024-10-24 13:40:20 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 2010
using namespace std;
const int MAX=1000000;
int n,point[N][2],arr[N][2],prex=MAX,prey;
int s=-1,cnt=0;
bool tf=0;
void getarr(){
for(int i=n-1;i>=0;i--){
arr[i][0]=point[(i+1)%n][0]-point[i][0];
arr[i][1]=point[(i+1)%n][1]-point[i][1];
}
}
int findstart(){
for(int i=0;i<n;i++){
if(arr[i][1]>0) return (i+1)%n;
}
return 0;
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>point[i][0]>>point[i][1];
}
getarr();
s=findstart();
for(int i=0;i<n;i++){
if(arr[(i+s)%n][1]<0){
prex=arr[(i+s)%n][0];
prey=arr[(i+s)%n][1];
tf=0;
continue;
}
if(arr[(i+s)%n][0]>0&&prex!=MAX&&arr[(i+s)%n][1]==0){
tf=1;
continue;
}
if(prex!=MAX&&arr[(i+s)%n][1]>0&&prex*arr[(i+s)%n][1]-prey*arr[(i+s)%n][0]>0){
cnt++;
prex=MAX;
tf=0;
continue;
}
if(tf==1&&arr[(i+s)%n][1]>0&&prex!=MAX){
cnt++;
tf=0;
}
prex=MAX-1;
}
cout<<cnt;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 3620kb
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: 3620kb
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: 0
Accepted
time: 0ms
memory: 3608kb
input:
6 0 0 2 0 1 1 4 1 5 0 3 4
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
8 0 0 1 0 3 -1 3 0 1 1 4 1 5 0 3 4
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
5 0 0 170 0 140 30 60 30 0 70
output:
2
result:
wrong answer 1st numbers differ - expected: '1', found: '2'