QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#376828 | #2174. Which Planet is This?! | installb# | TL | 292ms | 21684kb | C++20 | 1.9kb | 2024-04-04 17:04:18 | 2024-04-04 17:04:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N = 3600000;
int n;
vector <int> va[N],vb[N];
int pB[2][N],sa[N],sb[N],hb[2][N];
int mp[N + 5];
int f[N];
void getfail(int sz){
int j=0;
for(int i=2;i<=n;i++){
while(j && sa[i]!=sa[j+1])j=f[j];
if(sa[i] == sa[j+1])j++;
f[i]=j;
}
}
bool solve(){
cin >> n;
for(int i = 1;i <= n;i ++){
db x,y; cin >> x >> y;
int cx = x * 10000 + 0.1 + 900000;
int cy = y * 10000 + 0.1 + 1800000;
va[cx].push_back(cy%N);
}
for(int i = 1;i <= n;i ++){
db x,y; cin >> x >> y;
int cx = x * 10000 + 0.1 + 900000;
int cy = y * 10000 + 0.1 + 1800000;
vb[cx].push_back(cy%N);
}
int num = 0;
for(int i = 0;i <= 1800000;i ++){
if(va[i].size() != vb[i].size()) return 0;
if(va[i].size() == 0) continue;
num ++;
sort(va[i].begin(),va[i].end());
sort(vb[i].begin(),vb[i].end());
int sz = va[i].size();
for(int j = 1;j < sz;j ++) sa[j] = (va[i][j] - va[i][j - 1] + N) % N;
sa[sz] = (va[i][0] - va[i].back() + N) % N;
for(int j = 1;j < sz;j ++) sb[j] = (vb[i][j] - vb[i][j - 1] + N) % N;
sb[sz] = (vb[i][0] - vb[i].back() + N) % N;
for(int j = sz + 1;j <= sz + sz;j ++) sb[j] = sb[j - sz];
getfail(sz);
for(int j = 1,k=0;j < sz + sz;j ++){
while(k && sb[j] != sa[k+1])k=f[k];
if(sb[j] == sa[k+1])k++;
if(k == sz){
mp[(vb[i][j - sz] - va[i][0] + N) % N] ++;
k=f[k];
}
}
}
for(int i = 0;i <= N;i ++) if(mp[i] == num) return 1;
return 0;
}
int main(){
ios::sync_with_stdio(false);
cout << (solve() ? "Same" : "Different") << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 9ms
memory: 3796kb
input:
3 10 0 20 40 30 -15 40 -15 20 0 30 40
output:
Different
result:
ok single line: 'Different'
Test #2:
score: 0
Accepted
time: 292ms
memory: 21684kb
input:
359998 -0.0045 96.8638 -0.0045 -79.2284 -0.0045 -50.4113 -0.0045 -79.0394 -0.0045 -24.9710 -0.0045 -142.9880 -0.0045 50.6344 -0.0045 125.9464 -0.0045 -17.3039 -0.0045 42.3454 -0.0045 130.6138 -0.0045 -106.4363 -0.0045 -95.9378 -0.0045 90.7312 -0.0045 75.7615 -0.0045 -66.9785 -0.0045 -81.0752 -0.0045...
output:
Same
result:
ok single line: 'Same'
Test #3:
score: 0
Accepted
time: 251ms
memory: 16392kb
input:
299998 -0.0045 -42.0335 -0.0045 -106.8631 -0.0045 176.8211 -0.0045 100.6703 -0.0045 168.0453 -0.0045 -100.7977 -0.0045 -31.7881 -0.0045 -43.3799 -0.0045 -87.3392 -0.0045 30.4474 -0.0045 -7.4550 -0.0045 106.5476 -0.0045 -3.9185 -0.0045 -56.8153 -0.0045 -146.7755 -0.0045 -76.6043 -0.0045 57.1774 -0.00...
output:
Same
result:
ok single line: 'Same'
Test #4:
score: -100
Time Limit Exceeded
input:
400000 -57.6217 51.8207 -66.4301 79.8153 68.6538 169.5723 -48.0781 -6.6298 -6.7822 -17.1276 -39.4009 179.3474 63.3867 -77.7996 61.0296 23.9060 -45.3758 41.1641 70.4582 129.4273 -29.7325 -35.5175 -15.3621 31.2737 -23.1798 102.5020 80.7571 -132.1432 -48.3888 -6.5756 18.4703 135.7623 -0.8199 -65.5536 -...