답안 #105580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105580 2019-04-13T17:37:31 Z keko37 Pick (COI18_pick) C++14
10 / 100
2 ms 384 KB
#include<bits/stdc++.h>

using namespace std;

int a, b, c, d;
bool ab, cd;
string s;
vector < pair <int, int> > v;

void obradi () {
    int cx = 0, cy = 0;
    int len = s.size();
    for (int i=0; i<len; i++) {
        v.push_back(make_pair(cx, cy));
        if (s[i] == 'a') cx++; else if (s[i] == 'A') cx--;
        if (s[i] == 'b') cy++; else if (s[i] == 'B') cy--;
        if (s[i] == 'c') {cx++; cy++;} else if (s[i] == 'C') {cx--; cy--;}
        if (s[i] == 'd') {cx--; cy++;} else if (s[i] == 'D') {cx++; cy--;}
    }
}

void ispis () {
    if (ab) {
        for (int i=0; i<v.size(); i++) {
            swap(v[i].first, v[i].second);
        }
    }
    if (cd) {
        for (int i=0; i<v.size(); i++) {
            v[i].second = -v[i].second;
        }
    }
    for (int i=0; i<v.size(); i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }
}

int main () {
    cin >> a >> b >> c >> d;
    if (c == 0 && d == 0) {
        for (int i=0; i<a/2; i++) s += 'a';
        s += 'b';
        for (int i=0; i<a/2-1; i++) s += 'A';
        for (int i=0; i<b/2-1; i++) s += 'b';
        s += 'A';
        for (int i=0; i<b/2; i++) s += 'B';
    } else if (a == 0 && b == 0) {
        for (int i=0; i<c/2; i++) s += 'c';
        s += 'd';
        for (int i=0; i<c/2-1; i++) s += 'C';
        for (int i=0; i<d/2-1; i++) s += 'd';
        s += 'C';
        for (int i=0; i<d/2; i++) s += 'D';
    } else {
        if (a == 0) {
            swap(a, b);
            ab = 1;
        }
        if (c%2 == 0) {
            swap(c, d);
            cd = 1;
        }
        if (a%2 == 0 && b%2 == 0 && c%2 == 0 && d%2 == 0) {
            for (int i=0; i<a/2; i++) s += 'a';
            s += 'c';
            for (int i=0; i<b/2; i++) s += 'b';
            for (int i=0; i<c/2-1; i++) s += 'c';
            for (int i=0; i<d/2; i++) s += 'd';
            s += 'A';
            for (int i=0; i<d/2; i++) s += 'D';
            for (int i=0; i<c/2-1; i++) s += 'C';
            for (int i=0; i<b/2; i++) s += 'B';
            for (int i=0; i<a/2-1; i++) s += 'A';
            s += 'C';
        } else if (a%2 == 0 && b%2 == 0 && c%2 == 1 && d%2 == 1) {
            for (int i=0; i<(a-2)/2; i++) s += 'a';
            s += 'c';
            for (int i=0; i<b/2; i++) s += 'b';
            for (int i=0; i<(c-1)/2; i++) s += 'c';
            for (int i=0; i<(d-1)/2; i++) s += 'd';
            s += 'A';
            for (int i=0; i<(d-1)/2; i++) s += 'D';
            for (int i=0; i<(c-1)/2; i++) s += 'C';
            for (int i=0; i<b/2; i++) s += 'B';
            for (int i=0; i<(a-2)/2; i++) s += 'A';
            s += 'A';
            s += 'D';
        } else if (a%2 == 1 && b%2 == 1 && c%2 == 1 && d%2 == 0) {
            for (int i=0; i<(a-1)/2; i++) s += 'a';
            s += 'c';
            for (int i=0; i<(b-1)/2; i++) s += 'b';
            for (int i=0; i<(c-1)/2; i++) s += 'c';
            for (int i=0; i<d/2; i++) s += 'd';
            s += 'A';
            for (int i=0; i<d/2; i++) s += 'D';
            for (int i=0; i<(c-1)/2; i++) s += 'C';
            for (int i=0; i<(b-1)/2; i++) s += 'B';
            for (int i=0; i<(a-1)/2; i++) s += 'A';
            s += 'B';
        }
    }
    obradi();
    ispis();
    return 0;
}

Compilation message

pick.cpp: In function 'void ispis()':
pick.cpp:24:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0; i<v.size(); i++) {
                       ~^~~~~~~~~
pick.cpp:29:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0; i<v.size(); i++) {
                       ~^~~~~~~~~
pick.cpp:33:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<v.size(); i++) {
                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 128 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Incorrect 2 ms 384 KB not a valid stick
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Incorrect 2 ms 384 KB not a valid stick
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Incorrect 2 ms 384 KB not a valid stick
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Incorrect 2 ms 384 KB not a valid stick
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Incorrect 2 ms 384 KB not a valid stick
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 128 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Incorrect 2 ms 384 KB not a valid stick
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 128 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Incorrect 2 ms 384 KB not a valid stick
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 128 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Incorrect 2 ms 384 KB not a valid stick
16 Halted 0 ms 0 KB -