QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#645154#5426. Drain the Water TanktsaiWA 0ms3956kbC++14995b2024-10-16 17:04:582024-10-16 17:04:59

Judging History

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

  • [2024-10-16 17:04:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3956kb
  • [2024-10-16 17:04:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct node{
	int x;
	int y;
}no[1000050];
void solve(){
	int n;
	scanf("%d",&n);
	int minix=100005;
	int st=0;
	for(int i=0;i<=n-1;i++){
		scanf("%d %d",&no[i].x,&no[i].y);
	}
	for(int i=0;i<n-1;i++){
		if(no[i+1].y==no[i].y){
			st++;
		}else{
			break;
		}
	}	
	int l=st,mid,r;
	mid=(l+1)%n;r=(mid+1)%n;
	int cnt=0;
	while(1){
		while(no[r].y==no[mid].y){
			r=(r+1)%n;
		}
		r=(mid+1)%n;
		if(r==(l+2)%n){
			if(no[l].y>no[mid].y&&no[r].y>no[mid].y){
				if(no[r].x>no[mid].x||no[mid].x<no[r].x){
					cnt++;
				}
			}
		}else{
			if(no[l].y>no[mid].y&&no[r].y>no[mid].y){
				if(no[r].x>no[mid].x){
					cnt++;
				}
			}
		}
		l=mid;mid++;
		mid%=n;
		r=(mid+1)%n;
		if(l==st){
			break;
		}
	}
	printf("%d",cnt);
}

int main(){
	int t=1;
//	scanf("%d",&t);
	while(t--){
		solve();
		if(t) printf("\n");
	}
	return 0;
}
/*
10
1 0
2 0
3 0
2 1
3 2
2 2
1 2
0 2
1 1
0 0
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3956kb

input:

6
0 0
1 1
2 1
3 0
3 2
0 2

output:

1

result:

wrong answer 1st numbers differ - expected: '2', found: '1'