QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55373 | #4865. Symmetry: Convex | Juno | WA | 74ms | 3688kb | C++17 | 3.1kb | 2022-10-13 14:09:38 | 2022-10-13 14:09:39 |
Judging History
answer
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
const ll INF=4e18;
struct point {
using T=ll;
T x,y;
point(){}
point(T x,T y):x(x),y(y){}
bool operator==(point b)const{return x==b.x&&y==b.y;}
point operator+(point b)const{return point(x+b.x,y+b.y);}
point operator-(point b)const{return point(x-b.x,y-b.y);}
T operator*(point b)const{return x*b.x+y*b.y;}
T operator/(point b)const{return x*b.y-y*b.x;}
bool operator<(point b)const{return y==b.y?x<b.x:y<b.y;}
inline int sgn(){return y<0||(y==0&&x<0);}
};
int n;
point v[300010];
pll a[600010];
int pr[600010];
vector<pair<pll,ll>> ans;
void manacher() {
int len=2*n+1;
int p=-1,r=-1;
for(int i=0;i<len;i++) {
if(i<=r)pr[i]=min(pr[2*p-i],r-i);
else pr[i]=0;
while(i-pr[i]-1>=0&&i+pr[i]+1<len&&a[i-pr[i]-1]==a[i+pr[i]+1])pr[i]++;
if(r<i+pr[i])r=i+pr[i],p=i;
}
}
bool is_palindrome(int l,int r) {
int m=(l+r)/2;
m=m*2+1;
if((r-l)%2)m++;
return m-pr[m]<=2*l+1;
}
void add_perpen_line(int i,int j) {
point d=v[i]-v[j];
ll a=2*d.x;
ll b=2*d.y;
ll c=-(v[i].x*v[i].x-v[j].x*v[j].x)-(v[i].y*v[i].y-v[j].y*v[j].y);
ans.pb({{a,b},c});
}
void add_line(int i,int j) {
point d=v[i]-v[j];
d.y=-d.y;
swap(d.x,d.y);
ll a=d.x;
ll b=d.y;
ll c=v[i].x*v[j].y-v[j].x*v[i].y;
ans.pb({{a,b},c});
}
bool is_center(int i) {
int j=(i-1+n)%n;
int k=(i+1)%n;
point d1=v[j]-v[i];
point d2=v[k]-v[i];
return d1.x*d1.x+d1.y*d1.y==d2.x*d2.x+d2.y*d2.y;
}
void MAIN() {
cin>>n;
for(int i=0;i<n;i++) {
cin>>v[i].x>>v[i].y;
}
v[n]=v[0];
for(int i=0;i<n;i++) {
int j=(i-1+n)%n;
int k=(i+1)%n;
a[2*i]={INF,INF};
a[2*i+1]={(v[k]-v[i])*(v[k]-v[i]),(v[k]-v[i])/(v[k]-v[i])};
}
a[2*n]={INF,INF};
manacher();
map<pll,vector<int>> mp;
pll a1={(v[2]-v[1])*(v[0]-v[1]),(v[2]-v[1])/(v[0]-v[1])};
mp[a1]={1};
for(int i=2;i<n;i++) {
ans.clear();
pll al={(v[1]-v[0])*(v[i]-v[0]),(v[1]-v[0])/(v[i]-v[0])};
pll ar={(v[0]-v[i])*(v[i-1]-v[i]),(v[0]-v[i])/(v[i-1]-v[i])};
pll ai={(v[i+1]-v[i])*(v[i-1]-v[i]),(v[i+1]-v[i])/(v[i-1]-v[i])};
if(mp.count(al)) {
vector<int>& lst=mp[al];
for(int j:lst) {
pll aj={(v[j+1]-v[j])*(v[j-1]-v[j]),(v[j+1]-v[j])/(v[j-1]-v[j])};
if(ar==aj&&is_palindrome(0,j)&&(i==j+1||is_palindrome(j+2,i-1))) {
if(j%2||is_center(j/2)) {
add_perpen_line(0,j);
}
}
}
}
if(ar==al&&is_palindrome(1,i-1)) {
add_perpen_line(0,i);
}
if(ar==a1&&(i==2||is_palindrome(2,i-1))&&is_center(0)) {
if(i%2)add_line(0,(i+1)/2);
else add_perpen_line(i/2,i/2+1);
}
cout<<sz(ans)<<'\n';
for(auto& it:ans) {
cout<<it.fi.fi<<' '<<it.fi.se<<' '<<it.se<<'\n';
}
if(!mp.count(ai)) {
mp[ai]={i};
} else {
mp[ai].pb(i);
}
}
}
int main() {
ios::sync_with_stdio(false);cin.tie(0);
int T;cin>>T;
for(int tt=1;tt<=T;tt++) {
MAIN();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3584kb
input:
3 4 0 0 1 0 1 1 0 1 3 0 0 3 0 1 1 4 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
output:
1 -2 -2 2 4 -2 0 1 -2 -2 2 0 -2 1 1 -1 0 0 1 -4000000000 -4000000000 0 4 -4000000000 0 0 -4000000000 -4000000000 0 0 -4000000000 0 2000000000 -2000000000 0
result:
ok 3 test cases (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
1 4 0 0 1 0 2 2 1 2
output:
0 0
result:
ok 1 test cases (1 test case)
Test #3:
score: -100
Wrong Answer
time: 74ms
memory: 3520kb
input:
100000 3 0 0 137 967 -137 967 3 613 141 -613 141 0 0 3 0 0 165 58 -165 58 3 971 78 -971 78 0 0 3 627 119 -627 119 0 0 3 -252 233 0 0 252 233 3 0 0 193 11 -193 11 3 73 4 -73 4 0 0 3 0 0 464 613 -464 613 3 0 0 559 461 -559 461 3 0 0 760 61 -760 61 3 0 0 196 865 -196 865 3 386 825 -386 825 0 0 3 0 0 14...
output:
1 548 0 0 0 1 660 0 0 0 0 1 -1008 0 0 1 772 0 0 0 1 1856 0 0 1 2236 0 0 1 3040 0 0 1 784 0 0 0 1 576 0 0 1 1760 0 0 1 -1796 0 0 1 -3624 0 0 1 -376 0 0 1 -1484 0 0 1 988 0 0 1 28 0 0 0 0 1 164 0 0 0 1 -1708 0 0 1 -1192 0 0 0 1 940 0 0 1 1084 0 0 0 1 1172 0 0 0 0 1 296 0 0 0 1 2716 0 0 0 1 -612 0 0 1 ...
result:
wrong answer the participant are greater than answer (test case 2)