Submission #1001081
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define p pair<int,int> #define x first #define y second // num, p rot(p pt){ p d; d.x = pt.y; d.y = -pt.x; return d; } vector<p> solve(vector<int> d){ if(d.size() == 4){ vector<p> ans; ans.push_back(p(0, 0)); ans.push_back(p(1, 0)); ans.push_back(p(1, 1)); ans.push_back(p(0, 1)); return ans; } vector<int> newd; int n = d.size(); int sh = 0; for(int i = 0; i < d.size(); i++){ if(d[i%n] == 90 && d[(i+1)%n] == 90 && d[(i+2)%n] == 270) sh = i; } for(int i = 0; i < d.size(); i++){ newd.push_back(d[(i+sh)%n]); } //newd is d (question) wrapped around vector<int> dsmall; for(int i = 0; i < d.size(); i++){ if(i != 1 && i != 2) dsmall.push_back(newd[i]); } vector<p> asmall = solve(dsmall); //solution to wrapped around /*for(int i = 0; i < dsmall.size(); i++){ cout << dsmall[i] << " "; } cout << endl; for(int i = 0; i < dsmall.size(); i++){ cout << asmall[i].x << "," << asmall[i].y << " "; } cout << endl;*/ int nrot = 0; while((asmall[asmall.size()-1].y != asmall[0].y) || (asmall[asmall.size()-1].x > asmall[0].x)){ nrot++; for(int i = 0; i < asmall.size(); i++){ asmall[i] = rot(asmall[i]); } } /*cout << nrot << endl; for(int i = 0; i < dsmall.size(); i++){ cout << asmall[i].x << "," << asmall[i].y << " "; } cout << endl;*/ // asmall has horizontal right segment int sx = asmall[0].x; int sy = asmall[0].y; for(int i = 0; i < asmall.size(); i++){ if(asmall[i].x > sx) asmall[i].x+=2; if(asmall[i].x < sx) asmall[i].x-=2; if(asmall[i].y > sy) asmall[i].y+=2; if(asmall[i].y < sy) asmall[i].y-=2; } vector<p> ans; ans.push_back(p(asmall[0].x+1,asmall[0].y)); ans.push_back(p(asmall[0].x+1,asmall[0].y+1)); ans.push_back(p(asmall[0].x,asmall[0].y+1)); for(int i = 1; i < asmall.size(); i++){ ans.push_back(asmall[i]); } for(int cc = 0; cc < 4-nrot; cc++){ for(int i = 0; i < ans.size(); i++){ ans[i] = rot(ans[i]); } } vector<p> finans; for(int i = 0; i < ans.size(); i++){ finans.push_back(ans[(n-sh+i)%n]); } /*for(int i = 0; i < d.size(); i++){ cout << d[i] << " "; } cout << endl; for(int i = 0; i < ans.size(); i++){ cout << finans[i].x << "," << finans[i].y << " "; } cout << endl << endl;*/ return finans; } int main(){ int n; cin >> n; int a[n]; int d = 0; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n; i++){ if(a[i] == 90) d++; if(a[i] == 270) d--; } int flip = 0; if(d == -4){ flip = 1; d = -d; } if(d != 4){ cout << -1 << endl; return 0; } vector<int> pr; for(int i = 0; i < n; i++) pr.push_back(a[i]); vector<p> ttt = solve(pr); for(int i = 0; i < ttt.size(); i++){ cout << ttt[i].x+10000000 << " " << ttt[i].y+10000000 << endl; } }
Submission Info
Submission Time | |
---|---|
Task | I - 90 and 270 |
User | ksun48 |
Language | C++14 (GCC 5.4.1) |
Score | 1500 |
Code Size | 2919 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 3968 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1500 / 1500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.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, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 3 ms | 256 KB |
001.txt | AC | 3 ms | 256 KB |
002.txt | AC | 3 ms | 256 KB |
003.txt | AC | 13 ms | 2176 KB |
004.txt | AC | 5 ms | 512 KB |
005.txt | AC | 7 ms | 896 KB |
006.txt | AC | 10 ms | 1536 KB |
007.txt | AC | 6 ms | 640 KB |
008.txt | AC | 4 ms | 384 KB |
009.txt | AC | 7 ms | 768 KB |
010.txt | AC | 15 ms | 2688 KB |
011.txt | AC | 3 ms | 256 KB |
012.txt | AC | 8 ms | 1152 KB |
013.txt | AC | 9 ms | 1152 KB |
014.txt | AC | 4 ms | 384 KB |
015.txt | AC | 5 ms | 512 KB |
016.txt | AC | 11 ms | 1664 KB |
017.txt | AC | 3 ms | 256 KB |
018.txt | AC | 9 ms | 1280 KB |
019.txt | AC | 6 ms | 640 KB |
020.txt | AC | 19 ms | 3712 KB |
021.txt | AC | 3 ms | 256 KB |
022.txt | AC | 18 ms | 3456 KB |
023.txt | AC | 21 ms | 3968 KB |
024.txt | AC | 21 ms | 3968 KB |
025.txt | AC | 21 ms | 3968 KB |
026.txt | AC | 21 ms | 3968 KB |
027.txt | AC | 21 ms | 3968 KB |
028.txt | AC | 21 ms | 3968 KB |
029.txt | AC | 21 ms | 3968 KB |
030.txt | AC | 21 ms | 3968 KB |
031.txt | AC | 21 ms | 3968 KB |
032.txt | AC | 21 ms | 3968 KB |
033.txt | AC | 21 ms | 3968 KB |
034.txt | AC | 21 ms | 3968 KB |
035.txt | AC | 21 ms | 3968 KB |
036.txt | AC | 21 ms | 3968 KB |
037.txt | AC | 21 ms | 3968 KB |
038.txt | AC | 21 ms | 3968 KB |
039.txt | AC | 21 ms | 3968 KB |
040.txt | AC | 21 ms | 3968 KB |
041.txt | AC | 21 ms | 3968 KB |
042.txt | AC | 20 ms | 3968 KB |
043.txt | AC | 3 ms | 256 KB |
example0.txt | AC | 3 ms | 256 KB |
example1.txt | AC | 3 ms | 256 KB |