QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#21835 | #2838. 2D Geometry | CCPSDCGK# | WA | 3ms | 3672kb | C++20 | 2.5kb | 2022-03-08 16:34:04 | 2022-05-08 04:08:17 |
Judging History
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=rand30()%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;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3672kb
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'