Submission #208204

#TimeUsernameProblemLanguageResultExecution timeMemory
208204E869120Scissors and Tape (CEOI19_scissors)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #pragma warning (disable: 4996) int N; vector<pair<double, double>> X; int M; vector<pair<double, double>> Y; double G; double ax[1 << 18], ay[1 << 18], bx[1 << 18], by[1 << 18]; double cx[1 << 18], cy[1 << 18], dx[1 << 18], dy[1 << 18]; bool trans[1 << 18]; bool equal(double ap, double bp) { if (fabs(ap - bp) < 1.0 / 1200.0) return true; if (min(ap, bp) / max(ap, bp) >= 1199.0 / 1200.0) return true; return false; } void solve(double H1, double W1, double H2, double W2, int idx) { if (equal(H1, H2) && equal(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; } if (H1 == W2 && H2 == W1) { 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] = true; G = idx; return; } double c[4] = { H1, H2, W1, W2 }; sort(c, c + 4); double v1 = c[0], v2 = c[2]; if (H1 == v2 || W1 == v1) swap(v1, v2); double w1 = v1, w2 = v2; if (H2 == v1 || W2 == v2) { trans[idx] = false; } if (H2 == v2 || W2 == v1) { trans[idx] = true; swap(w1, w2); } double c1 = 0, c2 = 0; double 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. 最大座標を求める double px = 0, py = 0; for (int i = 0; i < N; i++) { px = max(px, X[i].first); py = max(py, X[i].second); } double 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 (double 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)
 
scissors.cpp: In function 'bool equal(double, double)':
scissors.cpp:15:6: error: 'fabs' was not declared in this scope
  if (fabs(ap - bp) < 1.0 / 1200.0) return true;
      ^~~~
scissors.cpp:15:6: note: suggested alternative: 'labs'
  if (fabs(ap - bp) < 1.0 / 1200.0) return true;
      ^~~~
      labs