Submission #208201

#TimeUsernameProblemLanguageResultExecution timeMemory
208201E869120Scissors and Tape (CEOI19_scissors)C++14
0 / 100
67 ms68472 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #pragma warning (disable: 4996) int N; vector<pair<int, int>> X; int M; vector<pair<int, int>> Y; int G; int ax[1 << 18], ay[1 << 18], bx[1 << 18], by[1 << 18]; int cx[1 << 18], cy[1 << 18], dx[1 << 18], dy[1 << 18]; bool trans[1 << 18]; void solve(int H1, int W1, int H2, int W2, int idx) { if (H1 == H2 && W1 == W2) { ax[idx] = 0; ay[idx] = 0; bx[idx] = H1; by[idx] = W1; cx[idx] = 0; cy[idx] = 0; dx[idx] = H2; dy[idx] = W2; trans[idx] = false; G = idx; return; } int c[4] = { H1, H2, W1, W2 }; sort(c, c + 4); int v1 = c[0], v2 = c[2]; if (H1 == v2 || W1 == v1) swap(v1, v2); int w1 = v1, w2 = v2; if (H2 == v1 || W2 == v2) { trans[idx] = false; } if (H2 == v2 || W2 == v1) { trans[idx] = true; swap(w1, w2); } int c1 = 0, c2 = 0; int d1 = 0, d2 = 0; if (H1 == v1) { ax[idx] = 0; ay[idx] = W1 - v2; bx[idx] = H1; by[idx] = W1; c1 = H1; c2 = W1 - v2; } else if (W1 == v2) { ax[idx] = H1 - v1; ay[idx] = 0; bx[idx] = H1; by[idx] = W1; c1 = H1 - v1; c2 = W1; } if (H2 == w1) { cx[idx] = 0; cy[idx] = W2 - w2; dx[idx] = H2; dy[idx] = W2; d1 = H2; d2 = W2 - w2; } else if (W2 == w2) { cx[idx] = H2 - w1; cy[idx] = 0; dx[idx] = H2; dy[idx] = W2; d1 = H2 - w1; d2 = W2; } solve(c1, c2, d1, d2, idx + 1); } int main() { //FILE* in = freopen("in1.txt", "r", stdin); //FILE* out = freopen("out1.txt", "w", stdout); // ステップ 1. 入力 cin >> N; X.resize(N, make_pair(0, 0)); for (int i = 0; i < N; i++) cin >> X[i].first >> X[i].second; cin >> M; Y.resize(M, make_pair(0, 0)); for (int i = 0; i < M; i++) cin >> Y[i].first >> Y[i].second; // ステップ 2. 最大座標を求める int px = 0, py = 0; for (int i = 0; i < N; i++) { px = max(px, X[i].first); py = max(py, X[i].second); } int qx = 0, qy = 0; for (int i = 0; i < M; i++) { qx = max(qx, Y[i].first); qy = max(qy, Y[i].second); } // ステップ 3. 操作を行う solve(px, py, qx, qy, 1); // ステップ 4. 出力を行う cout << "scissors" << endl; cout << "0 " << G << endl; for (int i = 1; i <= G; i++) { cout << 4 << " " << ax[i] << " " << ay[i] << " " << bx[i] << " " << ay[i] << " " << bx[i] << " " << by[i] << " " << ax[i] << " " << by[i] << endl; } cout << "tape" << endl; cout << G; for (int i = 1; i <= G; i++) cout << " " << i; cout << endl; for (int i = 1; i <= G; i++) { if (trans[i] == false) cout << 4 << " " << cx[i] << " " << cy[i] << " " << dx[i] << " " << cy[i] << " " << dx[i] << " " << dy[i] << " " << cx[i] << " " << dy[i] << endl; if (trans[i] == true) cout << 4 << " " << dx[i] << " " << cy[i] << " " << dx[i] << " " << dy[i] << " " << cx[i] << " " << dy[i] << " " << cx[i] << " " << cy[i] << endl; } cout << 4 << " " << 0 << " " << 0 << " " << qx << " " << 0 << " " << qx << " " << qy << " " << 0 << " " << qy << endl; return 0; }

Compilation message (stderr)

scissors.cpp:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...