Submission #417895

# Submission time Handle Problem Language Result Execution time Memory
417895 2021-06-04T13:22:39 Z 최서현(#7474) RPS string (innopolis2021_final_C) C++17
0 / 100
1 ms 204 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define tiii tuple<int, int, int>
#define tiiii tuple<int, int, int, int>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
#define DEBUG

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    pii A[n];
    int a = 0, b = 0;
    for(int i = 0; i < n; ++i)
    {
        int x, y; cin >> x >> y;
        if((x ^ y) & 1) { cout << -1; return 0; }
        if(x + y < 0 || x < y) { cout << -1; return 0; }
        int z = x + y >> 1;
        A[i] = {x - a, z - b};
        if(A[i].ss < 0 || A[i].ff < A[i].ss) { cout << -1; return 0; }
        a = x; b = z;
    }

    bool flag = true;
    for(int i = 0; i < n; ++i)
    {
        if(A[i].ss == 0) { flag = (i % 2 == 0); break; }
        if(A[i].ff == A[i].ss) { flag = (i % 2 == 1); break; }
    }

    vector<pair<int, bool>> ans;

    int pr = 0;
    for(int i = 0; i < n; ++i)
    {
        if(flag)
        {
            pr += A[i].ff - A[i].ss;
            if(A[i].ss != 0)
            {
                ans.push_back({pr, flag});
                pr = A[i].ss;
                flag = false;
            }
        }
        else
        {
            pr += A[i].ss;
            if(A[i].ff != A[i].ss)
            {
                ans.push_back({pr, flag});
                pr = A[i].ff - A[i].ss;
                flag = true;
            }
        }
    }

    if(pr) ans.push_back({pr, flag});

    cout << ans.size() << '\n';
    for(auto i : ans) cout << i.ff << (i.ss ? " -\n" : " +\n");
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:33:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |         int z = x + y >> 1;
      |                 ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -