QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21836#2838. 2D GeometryCCPSDCGK#WA 3ms5576kbC++202.5kb2022-03-08 16:35:442022-05-08 04:08:19

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:08:19]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5576kb
  • [2022-03-08 16:35:44]
  • 提交

answer

#include<map>
#include<set>
#include<queue>
#include<deque>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
#define mkp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define fs fflush(stdout)
#define ump unordered_map
#define pq priority_queue
#define clz __builtin_clz
#define ctz __builtin_ctz
#define space putchar(' ')
#define enter putchar('\n')
#define sz(x) (int)x.size()
#define np next_permutation
#define clzl __builtin_clzll
#define par __builtin_parity
#define ctzl __builtin_ctzll
#define ppc __builtin_popcount
#define parl __builtin_parityll
#define all(x) x.begin(),x.end()
#define ppcl __builtin_popcountll
#define ms(x,y) memset(x,y,sizeof(x))
#define debug(x) cerr<<#x<<"= "<<(x)<<'\n'
template<class T> inline T &read(T &x){
	x=0;int f=1;char ch=getchar();
	while(ch<48||ch>57){if(ch=='-') f=-f;ch=getchar();}
	while(ch>=48&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*=f;
}
template<class T> inline void print(T x){
	static char buf[40];static int cnt=0;
	if(x<0) putchar(45),x=-x;
	do buf[++cnt]=x%10^48;while(x/=10);
	do putchar(buf[cnt--]);while(cnt);
}
#define mod 998244353
#define inf 0x3f3f3f3f
#define fpi freopen("","r",stdin)
#define fpo freopen("","w",stdout)
int x[200005],y[200005];
pair<int,int> p[200005];
inline int rand30(){return rand()<<15|rand();}
inline int gcd(int x,int y){int z;while(y) z=x,x=y,y=z%y;return x;}
void solve(int n){
	int maxn=0,i,tim=30;
	for(i=1;i<=n;i++) read(x[i]),read(y[i]);
	while(tim--){
		int pos=rand()%n+1,sumx=1,sumy=1,cnt=0,sum=1;
		for(i=1;i<=n;i++) if(i^pos) x[i]-=x[pos],y[i]-=y[pos];
		for(i=1;i<=n;i++) if(i^pos&&!x[i]) sumx++;
		for(i=1;i<=n;i++) if(i^pos&&!y[i]) sumy++;
		maxn=max(maxn,max(sumx,sumy));
		for(i=1;i<=n;i++) if(i^pos&&x[i]&&y[i]){int d=gcd(abs(x[i]),abs(y[i]));x[i]/=d,y[i]/=d;if(x[i]<0) x[i]=-x[i],y[i]=-y[i];p[++cnt]={x[i],y[i]};}
		sort(p+1,p+cnt+1);
		for(i=1;i<=cnt;i++){if(p[i]!=p[i-1]) maxn=max(maxn,sum),sum=1;sum++;}maxn=max(maxn,sum);
		for(i=1;i<=n;i++) if(i^pos) x[i]+=x[pos],y[i]+=y[pos];
	}
	print(max(0,maxn-((n-maxn)<<1))),enter;
}
int main(){
	int n;srand(time(0));
	while(cin>>n) solve(n);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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
0
0
2
0
5
0
0
0
0
0
0
0
0
3
6

result:

wrong answer 8th lines differ - expected: '2', found: '0'