QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#644623#5426. Drain the Water TanktsaiWA 1ms3952kbC++141.0kb2024-10-16 14:51:322024-10-16 14:51:33

Judging History

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

  • [2024-10-16 14:51:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3952kb
  • [2024-10-16 14:51:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct node{
	int x;
	int y;
}no[1000050];
vector<node>v;
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;
		}
	}
	for(int i=st;i<n;i++){
		v.push_back({no[i].x,no[i].y});
	}
	for(int i=0;i<=st;i++){
		v.push_back({no[i].x,no[i].y});
	}
	v.push_back({no[(st+1)%n].x,no[(st+1)%n].y});	
	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){
			mid++;
			mid%=n;
			r=(mid+1)%n;	
		}
		r=(mid+1)%n;
		if(no[l].y>no[mid].y&&no[r].y>no[mid].y){
			if(no[l].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: 100
Accepted
time: 1ms
memory: 3848kb

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: 1ms
memory: 3952kb

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: 3916kb

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: 3768kb

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'