Submission #2093497
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N;
vector<int> A;
vector<pair<int,int>> hoge(vector<int> A) {
if(A.size()==4) {
return {{0,0},{1,0},{1,1},{0,1}};
}
int i,N=A.size(),j;
FOR(i,N) {
if(A[i]==1 && A[(i+1)%N]==0) break;
}
vector<int> B;
B.push_back(A[(i+N-1)%N]);
FOR(j,N-3) B.push_back(A[(i+2+j)%N]);
vector<pair<int,int>> P=hoge(B),R;
while(P[0].first>=P[1].first) {
FORR(p,P) {
swap(p.first,p.second);
p.first=-p.first;
}
}
FORR(p,P) p.first*=2,p.second*=2;
P.insert(P.begin()+1,{P[0].first+1,P[0].second});
P.insert(P.begin()+2,{P[0].first+1,P[0].second+1});
P[3].second++;
vector<int> Xs,Ys;
FORR(p,P) {
Xs.push_back(p.first);
Ys.push_back(p.second);
}
sort(ALL(Xs));
sort(ALL(Ys));
Xs.erase(unique(ALL(Xs)),Xs.end());
Ys.erase(unique(ALL(Ys)),Ys.end());
FOR(j,N) {
int x=lower_bound(ALL(Xs),P[(j-(i-1)+N)%N].first)-Xs.begin();
int y=lower_bound(ALL(Ys),P[(j-(i-1)+N)%N].second)-Ys.begin();
R.push_back({x,y});
}
return R;
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
int rot=0;
FOR(i,N) {
cin>>x;
A.push_back(x==90);
if(A[i]==1) rot++;
else rot--;
}
if(rot!=4) return _P("-1\n");
auto ret=hoge(A);
FORR(r,ret) cout<<r.first<<" "<<r.second<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
I - 90 and 270 |
User |
kmjp |
Language |
C++14 (GCC 5.4.1) |
Score |
1500 |
Code Size |
1971 Byte |
Status |
AC |
Exec Time |
43 ms |
Memory |
2688 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 |
1 ms |
256 KB |
001.txt |
AC |
1 ms |
256 KB |
002.txt |
AC |
1 ms |
256 KB |
003.txt |
AC |
18 ms |
1408 KB |
004.txt |
AC |
4 ms |
512 KB |
005.txt |
AC |
7 ms |
640 KB |
006.txt |
AC |
13 ms |
1024 KB |
007.txt |
AC |
5 ms |
512 KB |
008.txt |
AC |
2 ms |
384 KB |
009.txt |
AC |
7 ms |
640 KB |
010.txt |
AC |
25 ms |
1792 KB |
011.txt |
AC |
2 ms |
256 KB |
012.txt |
AC |
11 ms |
896 KB |
013.txt |
AC |
11 ms |
896 KB |
014.txt |
AC |
2 ms |
384 KB |
015.txt |
AC |
4 ms |
384 KB |
016.txt |
AC |
16 ms |
1152 KB |
017.txt |
AC |
1 ms |
256 KB |
018.txt |
AC |
13 ms |
1024 KB |
019.txt |
AC |
6 ms |
512 KB |
020.txt |
AC |
36 ms |
2432 KB |
021.txt |
AC |
1 ms |
256 KB |
022.txt |
AC |
32 ms |
2304 KB |
023.txt |
AC |
37 ms |
2688 KB |
024.txt |
AC |
37 ms |
2688 KB |
025.txt |
AC |
38 ms |
2688 KB |
026.txt |
AC |
40 ms |
2688 KB |
027.txt |
AC |
40 ms |
2688 KB |
028.txt |
AC |
42 ms |
2688 KB |
029.txt |
AC |
40 ms |
2688 KB |
030.txt |
AC |
43 ms |
2688 KB |
031.txt |
AC |
43 ms |
2688 KB |
032.txt |
AC |
43 ms |
2688 KB |
033.txt |
AC |
43 ms |
2688 KB |
034.txt |
AC |
43 ms |
2688 KB |
035.txt |
AC |
43 ms |
2688 KB |
036.txt |
AC |
43 ms |
2688 KB |
037.txt |
AC |
43 ms |
2688 KB |
038.txt |
AC |
42 ms |
2688 KB |
039.txt |
AC |
41 ms |
2688 KB |
040.txt |
AC |
41 ms |
2688 KB |
041.txt |
AC |
40 ms |
2688 KB |
042.txt |
AC |
41 ms |
2688 KB |
043.txt |
AC |
1 ms |
256 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |