Submission #2038552
Source Code Expand
#include<stdio.h> #include<vector> #include<algorithm> using namespace std; typedef pair<int, int>pii; vector<pii>comp(vector<pii>v) { vector<int>za, zb; for (int i = 0; i < v.size(); i++)za.push_back(v[i].first), zb.push_back(v[i].second); sort(za.begin(), za.end()); sort(zb.begin(), zb.end()); for (int i = 0; i < v.size(); i++) { v[i].first = (lower_bound(za.begin(), za.end(), v[i].first) - za.begin()) * 2; v[i].second = (lower_bound(zb.begin(), zb.end(), v[i].second) - zb.begin()) * 2; } return v; } vector<pii>calc(vector<int>v) { if (v.size() == 4) { vector<pii>r; r.push_back(make_pair(0, 0)); r.push_back(make_pair(2, 0)); r.push_back(make_pair(2, 2)); r.push_back(make_pair(0, 2)); return r; } int rr = 0; for (int i = 0; i < v.size() - 1; i++) { if (v[i] != v[i + 1]) { rr = i; break; } } vector<int>z; for (int i = 0; i < rr; i++)z.push_back(v[i]); for (int i = rr + 2; i < v.size(); i++)z.push_back(v[i]); vector<pii>now = calc(z); vector<pii>ans; for (int i = 0; i < rr; i++)ans.push_back(now[i]); pii s = now[(rr + now.size() - 1) % now.size()], t = now[rr % now.size()]; pii a = make_pair((s.first + t.first) / 2, (s.second + t.second) / 2), b = a; if (s.first == t.first) { if ((s.second < t.second) == (v[rr] == 1))b.first--, t.first--; else b.first++, t.first++; } else { if ((s.first < t.first) == (v[rr] == 1))b.second++, t.second++; else b.second--, t.second--; } ans.push_back(a); ans.push_back(b); for (int i = rr; i < now.size(); i++)ans.push_back(now[i]); ans[(rr + 2) % ans.size()] = t; //for (int i = 0; i < v.size(); i++)printf("%d ", v[i]); printf("\n"); //for (int i = 0; i < ans.size(); i++)printf("%d %d ", ans[i].first, ans[i].second); printf("\n"); return comp(ans); } int main() { int num; scanf("%d", &num); vector<int>v; int s = 0; for (int i = 0; i < num; i++) { int z; scanf("%d", &z); v.push_back((180 - z) / 90); s += v[i]; } if (s != 4) { printf("-1\n"); return 0; } vector<pii>r = calc(v); for (int i = 0; i < num; i++)printf("%d %d\n", r[i].first, r[i].second); }
Submission Info
Submission Time | |
---|---|
Task | I - 90 and 270 |
User | DEGwer |
Language | C++ (GCC 5.4.1) |
Score | 1500 |
Code Size | 2193 Byte |
Status | AC |
Exec Time | 42 ms |
Memory | 2688 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:68:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &num); ^ ./Main.cpp:74:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &z); ^
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 | 2 ms | 384 KB |
001.txt | AC | 1 ms | 256 KB |
002.txt | AC | 1 ms | 256 KB |
003.txt | AC | 19 ms | 1408 KB |
004.txt | AC | 4 ms | 384 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 | 6 ms | 640 KB |
010.txt | AC | 25 ms | 1792 KB |
011.txt | AC | 2 ms | 256 KB |
012.txt | AC | 10 ms | 896 KB |
013.txt | AC | 10 ms | 896 KB |
014.txt | AC | 2 ms | 256 KB |
015.txt | AC | 3 ms | 384 KB |
016.txt | AC | 15 ms | 1152 KB |
017.txt | AC | 1 ms | 256 KB |
018.txt | AC | 12 ms | 896 KB |
019.txt | AC | 5 ms | 512 KB |
020.txt | AC | 35 ms | 2432 KB |
021.txt | AC | 1 ms | 256 KB |
022.txt | AC | 29 ms | 2304 KB |
023.txt | AC | 39 ms | 2688 KB |
024.txt | AC | 38 ms | 2688 KB |
025.txt | AC | 38 ms | 2688 KB |
026.txt | AC | 41 ms | 2688 KB |
027.txt | AC | 41 ms | 2688 KB |
028.txt | AC | 42 ms | 2688 KB |
029.txt | AC | 40 ms | 2688 KB |
030.txt | AC | 41 ms | 2688 KB |
031.txt | AC | 41 ms | 2688 KB |
032.txt | AC | 41 ms | 2688 KB |
033.txt | AC | 41 ms | 2688 KB |
034.txt | AC | 42 ms | 2688 KB |
035.txt | AC | 41 ms | 2688 KB |
036.txt | AC | 42 ms | 2688 KB |
037.txt | AC | 41 ms | 2688 KB |
038.txt | AC | 41 ms | 2688 KB |
039.txt | AC | 40 ms | 2688 KB |
040.txt | AC | 40 ms | 2688 KB |
041.txt | AC | 39 ms | 2688 KB |
042.txt | AC | 38 ms | 2688 KB |
043.txt | AC | 1 ms | 256 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |