QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21737#2838. 2D GeometryWhybullYMe#WA 3ms3824kbC++141.0kb2022-03-08 14:46:002022-05-08 04:00:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 04:00:34]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3824kb
  • [2022-03-08 14:46:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=2e5+10;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
int n;
int main(){
	while(~scanf("%d",&n)){
		int ans=0;
		typedef pair<int,int> pii;
		#define fi first
		#define se second
		vector<vector<pii>>v;
		for(ri i=1;i<=n;++i){
			pii p;
			scanf("%d%d",&p.fi,&p.se);
			for(auto &j:v){
				auto intersect=[&](pii x,pii y,pii z){
					return abs(1ll*(y.se-x.se)*(z.fi-y.fi))==abs(1ll*(z.se-y.se)*(y.fi-x.fi));
				};
				if(j.empty())continue;
				else if(j.size()==1){j.push_back(p);goto skip;}
				else if(intersect(j[j.size()-2],j[j.size()-1],p)){j.push_back(p);goto skip;}
				else{ans+=3,j.pop_back(),j.pop_back();goto skip;}
			}
			v.push_back({p});
			skip:;
		}
		printf("%d\n",n-ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3824kb

input:

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

output:

3
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3728kb

input:

1
0 0
2
0 0
1 1
3
0 0
0 1
0 2
3
0 0
0 1
1 0
4
3 0
0 2
3 3
3 1
4
2 3
1 1
0 3
0 2
4
0 0
0 3
0 2
0 1
5
8 6
9 2
2 3
7 4
1 5
5
2 2
4 2
6 2
7 2
0 4
5
3 7
5 4
4 4
9 4
9 9
5
5 4
5 9
5 5
4 3
1 0
5
3 2
1 2
7 2
6 2
5 2
6
7 2
7 9
0 3
8 8
4 4
3 8
6
2 8
2 5
3 5
3 8
2 0
0 2
6
2 3
8 4
2 9
2 2
2 6
4 9
6
2 1
7 6
6 5
...

output:

1
2
3
0
1
1
4
2
2
2
2
5
0
0
0
0
3
0
0
3
0
6

result:

wrong answer 17th lines differ - expected: '0', found: '3'