QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671605#5426. Drain the Water Tankhansue#WA 0ms3628kbC++201.0kb2024-10-24 13:40:202024-10-24 13:40:20

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 13:40:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-10-24 13:40:20]
  • 提交

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;

}

詳細信息

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'