Submission #23753696
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
using pi=pair<int,int>;
bool comp(const pi &l,const pi &r){
double atl=atan2((double)l.second,(double)l.first);
double atr=atan2((double)r.second,(double)r.first);
return (atl!=atr)?(atl<atr):((l.first*l.first+l.second*l.second)<(r.first*r.first+r.second*r.second));
}
void z_algorithm(vector<int> &s,vector<int> &arr){
int i,j,k,l;
l=s.size();
arr[0]=l;
i=1;j=0;
while(i<l){
while((i+j)<l){
if(s[j]!=s[i+j]){break;}
j++;
}
arr[i]=j;
if(j==0){i++;continue;}
k=1;
while((i+k)<l){
if(k+arr[k]>=arr[i]){break;}
arr[i+k]=arr[k];
k++;
}
j=arr[i]-k;
i+=k;
}
}
vector<int> pts_to_str(vector<pi> pts){
vector<int> res;
int gx=0,gy=0;
for(auto &nx : pts){gx+=nx.first;gy+=nx.second;}
gx/=((int)pts.size());
gy/=((int)pts.size());
vector<pi> vcs;
for(auto &nx : pts){
int vx=nx.first-gx;
int vy=nx.second-gy;
if(vx==0 && vy==0){continue;}
vcs.push_back({vx,vy});
}
sort(vcs.begin(),vcs.end(),comp);
int sz=vcs.size();
for(int i=0;i<sz;i++){
res.push_back(vcs[i].first*vcs[i].first+vcs[i].second*vcs[i].second);
res.push_back(vcs[i].first*vcs[(i+1)%sz].first+vcs[i].second*vcs[(i+1)%sz].second);
res.push_back(vcs[i].first*vcs[(i+1)%sz].second-vcs[i].second*vcs[(i+1)%sz].first);
}
return res;
}
int main(){
int n;
cin >> n;
if(n==1){cout << "Yes\n";return 0;}
vector<pi> a(n),b(n);
for(auto &nx : a){
cin >> nx.first >> nx.second;
nx.first*=n;nx.second*=n;
}
for(auto &nx : b){
cin >> nx.first >> nx.second;
nx.first*=n;nx.second*=n;
}
vector<int> as=pts_to_str(a);
vector<int> bs=pts_to_str(b);
if(as.size()!=bs.size()){cout << "No\n";return 0;}
int sz=as.size();
vector<int> zs;
zs.insert(zs.end(),as.begin(),as.end());
zs.insert(zs.end(),bs.begin(),bs.end());
zs.insert(zs.end(),bs.begin(),bs.end());
vector<int> zr(sz*3);
z_algorithm(zs,zr);
for(int j=sz;j<2*sz;j+=3){
if(zr[j]>=sz){cout << "Yes\n";return 0;}
}
cout << "No\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Congruence Points |
| User | physics0523 |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 2110 Byte |
| Status | AC |
| Exec Time | 7 ms |
| Memory | 3960 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt, example3.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, after_contest_01.txt, example0.txt, example1.txt, example2.txt, example3.txt, killer_T_01.txt, killer_T_02.txt, killer_T_03.txt, killer_T_04.txt, killer_T_05.txt, killer_T_06.txt, killer_T_07.txt, killer_T_08.txt, killer_T_09.txt, killer_T_10.txt, killer_T_11.txt, killer_T_12.txt, killer_T_13.txt, killer_T_14.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 7 ms | 3392 KiB |
| 001.txt | AC | 2 ms | 3632 KiB |
| 002.txt | AC | 4 ms | 3888 KiB |
| 003.txt | AC | 3 ms | 3644 KiB |
| 004.txt | AC | 2 ms | 3748 KiB |
| 005.txt | AC | 2 ms | 3792 KiB |
| 006.txt | AC | 2 ms | 3892 KiB |
| 007.txt | AC | 2 ms | 3764 KiB |
| 008.txt | AC | 2 ms | 3784 KiB |
| 009.txt | AC | 2 ms | 3812 KiB |
| 010.txt | AC | 3 ms | 3784 KiB |
| 011.txt | AC | 2 ms | 3884 KiB |
| 012.txt | AC | 3 ms | 3748 KiB |
| 013.txt | AC | 3 ms | 3792 KiB |
| 014.txt | AC | 2 ms | 3956 KiB |
| 015.txt | AC | 2 ms | 3640 KiB |
| 016.txt | AC | 2 ms | 3872 KiB |
| 017.txt | AC | 2 ms | 3960 KiB |
| 018.txt | AC | 2 ms | 3844 KiB |
| 019.txt | AC | 2 ms | 3844 KiB |
| 020.txt | AC | 2 ms | 3852 KiB |
| 021.txt | AC | 2 ms | 3776 KiB |
| 022.txt | AC | 2 ms | 3620 KiB |
| 023.txt | AC | 2 ms | 3944 KiB |
| 024.txt | AC | 2 ms | 3732 KiB |
| 025.txt | AC | 2 ms | 3812 KiB |
| 026.txt | AC | 2 ms | 3876 KiB |
| 027.txt | AC | 2 ms | 3620 KiB |
| 028.txt | AC | 2 ms | 3880 KiB |
| 029.txt | AC | 2 ms | 3764 KiB |
| 030.txt | AC | 2 ms | 3640 KiB |
| 031.txt | AC | 2 ms | 3324 KiB |
| 032.txt | AC | 2 ms | 3556 KiB |
| 033.txt | AC | 2 ms | 3568 KiB |
| 034.txt | AC | 2 ms | 3712 KiB |
| 035.txt | AC | 2 ms | 3520 KiB |
| 036.txt | AC | 2 ms | 3492 KiB |
| 037.txt | AC | 2 ms | 3424 KiB |
| 038.txt | AC | 2 ms | 3776 KiB |
| 039.txt | AC | 2 ms | 3640 KiB |
| 040.txt | AC | 1 ms | 3764 KiB |
| 041.txt | AC | 6 ms | 3744 KiB |
| 042.txt | AC | 2 ms | 3876 KiB |
| 043.txt | AC | 2 ms | 3772 KiB |
| 044.txt | AC | 2 ms | 3772 KiB |
| 045.txt | AC | 2 ms | 3636 KiB |
| after_contest_01.txt | AC | 2 ms | 3844 KiB |
| example0.txt | AC | 2 ms | 3840 KiB |
| example1.txt | AC | 2 ms | 3616 KiB |
| example2.txt | AC | 2 ms | 3880 KiB |
| example3.txt | AC | 2 ms | 3880 KiB |
| killer_T_01.txt | AC | 3 ms | 3776 KiB |
| killer_T_02.txt | AC | 2 ms | 3844 KiB |
| killer_T_03.txt | AC | 2 ms | 3956 KiB |
| killer_T_04.txt | AC | 2 ms | 3728 KiB |
| killer_T_05.txt | AC | 2 ms | 3632 KiB |
| killer_T_06.txt | AC | 3 ms | 3892 KiB |
| killer_T_07.txt | AC | 3 ms | 3844 KiB |
| killer_T_08.txt | AC | 3 ms | 3876 KiB |
| killer_T_09.txt | AC | 3 ms | 3880 KiB |
| killer_T_10.txt | AC | 2 ms | 3880 KiB |
| killer_T_11.txt | AC | 2 ms | 3812 KiB |
| killer_T_12.txt | AC | 2 ms | 3736 KiB |
| killer_T_13.txt | AC | 2 ms | 3612 KiB |
| killer_T_14.txt | AC | 3 ms | 3616 KiB |