답안 #260091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260091 2020-08-09T09:27:31 Z MarcoMeijer Scissors and Tape (CEOI19_scissors) C++14
0 / 100
22 ms 24320 KB
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()

// input
template<class T> void IN(T& x) {cin >> x;}
template<class H, class... T> void IN(H& h, T&... t) {IN(h); IN(t...); }

// output
template<class T1, class T2> void OUT(const pair<T1,T2>& x);
template<class T> void OUT(const complex<T>& x);
template<class T> void OUT(const vector<T>& x);
template<class T> void OUT(const T& x) {cout << x;}
template<class H, class... T> void OUT(const H& h, const T&... t) {OUT(h); OUT(t...); }
template<class... T> void OUTL(const T&... t) {OUT(t..., "\n"); }
template<class H> void OUTLS(const H& h) {OUTL(h); }
template<class H, class... T> void OUTLS(const H& h, const T&... t) {OUT(h,' '); OUTLS(t...); }
template<class T1, class T2> void OUT(const pair<T1,T2>& x) {OUT(x.fi,' ',x.se);}
template<class T> void OUT(const complex<T>& x) {OUT(x.real(),' ',x.imag());}
template<class T> void OUT(const vector<T>& x) { RE(i,x.sz) OUT(i==0?"":" ", x[i]); }

//===================//
//  Added libraries  //
//===================//

//===================//
//end added libraries//
//===================//

void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}


//===================//
//   begin program   //
//===================//

const int MX = 5e5;

typedef complex<double> Vec;
typedef vector<Vec> Shape;

Shape res;
Shape shapes[MX];
int n;

void read(Shape& s) {
    int n;
    IN(n);
    s.resize(n);
    RE(i,n) {
        double x, y;
        IN(x,y);
        s[i] = {x,y};
    }
}
void print(const Shape& s) {
    OUTLS(s.sz,s);
}
int moveShape(int s, const Shape& bg, const Shape& target) {
    OUTL("tape");
    OUTLS(1,s);
    print(bg);
    print(target);
    shapes[n] = target;
    return n++;
}
int moveShape(int s, const Shape& target) {
    return moveShape(s,target,target);
}
int rectToRect(int s, const Shape& t) {
    Shape& S = shapes[s];
    double xs=abs(S[0]-S[1]);
    double ys=abs(S[1]-S[2]);
    if(ys > xs) {
        swap(xs, ys);
        s = moveShape(s,{{xs,0},{xs,ys},{0,ys},{0,0}}, {{0,0},{xs,0},{xs,ys},{0,ys}});
    } else {
        s = moveShape(s,{{0,0},{xs,0},{xs,ys},{0,ys}});
    }

    double xt=abs(t[0]-t[1]);
    double yt=abs(t[1]-t[2]);
    bool swapped=0;
    if(yt < xt) swap(xt, yt), swapped=1;

    while(xs >= xt*2.0) {
        int a=n, b=n+1, c=n+2; n+=3;
        xs /= 2.0;

        shapes[a] = {{0,0},{xs,0},{xs,ys},{0,ys}};
        shapes[b] = {{xs,0},{2.0*xs,0},{2.0*xs,ys},{xs,ys}};
        OUTL("scissors");
        OUTLS(s,2);
        print(shapes[a]);
        print(shapes[b]);
        shapes[b] = {{0,ys},{xs,ys},{xs,2.0*ys},{0,2.0*ys}};

        ys *= 2.0;
        shapes[c] = {{0,0},{xs,0},{xs,ys},{0,ys}};


        OUTL("tape");
        OUTLS(2,a,b);
        print(shapes[a]);
        print(shapes[b]);
        print(shapes[c]);

        s = c;
    }

    double x = xs-xt;
    double y = yt-ys;

    assert(x >= 0.0);
    assert(y >= 0.0);

    int a=n, b=n+1, c=n+2, d=n+3; n+=4;
    shapes[a] = {{0,0},{xt,0},{xt,y},{x,ys},{0,ys}};
    shapes[b] = {{xt,0},{xt,y},{xs,0}};
    shapes[c] = {{xs,0},{xs,ys},{x,ys}};
    OUTL("scissors");
    OUTLS(s,3);
    print(shapes[a]);
    print(shapes[b]);
    print(shapes[c]);

    shapes[b] = {{0,ys},{x,ys},{0,yt}};
    shapes[c] = {{xt,y},{xt,yt},{0,yt}};
    shapes[d] = {{0,0},{xt,0},{xt,yt},{0,yt}};
    OUTL("tape");
    OUTLS(3,a,b,c);
    print(shapes[a]);
    print(shapes[b]);
    print(shapes[c]);
    print(shapes[d]);

    s = d;
    if(swapped) {
        s = moveShape(s,{{yt,0},{yt,xt},{0,xt},{0,0}},{{0,0},{yt,0},{yt,xt},{0,xt}});
    }

    return s;
}

void program() {
    read(shapes[n++]);
    read(res);

    int r = rectToRect(0,res);
}

Compilation message

scissors.cpp: In function 'void program()':
scissors.cpp:180:9: warning: unused variable 'r' [-Wunused-variable]
     int r = rectToRect(0,res);
         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12032 KB Operation 4, Polygon 1: Polygon given in clockwise order, must be counter-clockwise
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 12032 KB Operation 2, Polygon 1: Polygon given in clockwise order, must be counter-clockwise
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12032 KB Operation 4, Polygon 1: Polygon given in clockwise order, must be counter-clockwise
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 24320 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12032 KB Operation 1 (tape), polygon 0: Equivalent polygons must have same number of vertices (3 != 4)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12032 KB Operation 4, Polygon 1: Polygon given in clockwise order, must be counter-clockwise
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12032 KB Operation 4, Polygon 1: Polygon given in clockwise order, must be counter-clockwise
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12032 KB Operation 4, Polygon 1: Polygon given in clockwise order, must be counter-clockwise
2 Halted 0 ms 0 KB -