Submission #417865

# Submission time Handle Problem Language Result Execution time Memory
417865 2021-06-04T12:41:55 Z 최서현(#7474) Diamond Hands (innopolis2021_final_B) 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;

#define int long long
signed 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};
        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; }
    }

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

    if(pr)
    {
        if(flag) cout << pr << " -\n";
        else cout << pr << " +\n";
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:34:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         int z = x + y >> 1;
      |                 ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer 8 violates the range [-1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer 8 violates the range [-1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer 8 violates the range [-1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "+" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer 8 violates the range [-1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer 8 violates the range [-1, 4]
2 Halted 0 ms 0 KB -