QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21838#2838. 2D GeometryCCPSDCGK#WA 2ms5636kbC++202.4kb2022-03-08 16:37:502022-05-08 04:08:32

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:32]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5636kb
  • [2022-03-08 16:37:50]
  • 提交

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 xx[200005],yy[200005],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(xx[i]),read(yy[i]);
	while(tim--){
		int pos=rand30()%n+1,sumx=1,sumy=1,cnt=0,sum=1;
		for(i=1;i<=n;i++) if(i^pos) x[i]=xx[i]-xx[pos],y[i]=yy[i]-yy[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);
	}
	print(max(0,maxn-((n-maxn)<<1))),enter;
}
int main(){
	int n;srand(time(0));
	while(cin>>n) solve(n);
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5636kb

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:

6
3
3

result:

wrong answer 1st lines differ - expected: '3', found: '6'