提出 #1611268


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; ++i)
using ll = long long;

int main()
{
    ll x, y;
    cin >> x >> y;
    ll sm = 0ll;
    ll naname = min(abs(x), abs(y));
    // cerr << "naname = " << naname << endl;
    bool f0 = false;
    bool f1 = false;
    bool f2 = false;
    bool f3 = false;

    if (x > 0 && y > 0) {
        sm += 2 * naname;
        f0 = true;
    }
    else if (x < 0 && y > 0) {
        sm += 3 + 6 * (naname - 1);
        f1 = true;
    }
    else if (x < 0 && y < 0) {
        sm += 1 + 4 * (naname - 1);
        f2 = true;
    }
    else if (x > 0 && y < 0) {
        sm += 3 + 6 * (naname - 1);
        f3 = true;
    }

    x = (x > 0 ? +1 : -1) * (abs(x) - naname);
    y = (y > 0 ? +1 : -1) * (abs(y) - naname);
    // cerr << "x = " << x << ", y = " << y << ", sm = " << sm << endl;

    if (x > 0 && y == 0) {
        if (f3) {
            sm += 4 * abs(x);
        }
        else {
            sm += 1 + 4 * (abs(x) - 1);
        }
    }
    else if (x == 0 && y > 0) {
        if (f1) {
            sm += 4 * abs(y);
        }
        else {
            sm += 1 + 4 * (abs(y) - 1);
        }
    }
    else if (x < 0 && y == 0) {
        sm += 2 * abs(x);
    }
    else if (x == 0 && y < 0) {
        sm += 2 * abs(y);
    }

    cout << sm << endl;

}

提出情報

提出日時
問題 H - イベルタル
ユーザ SyntaxSato
言語 C++14 (GCC 5.4.1)
得点 1
コード長 1402 Byte
結果 AC
実行時間 1 ms
メモリ 256 KiB

ジャッジ結果

セット名 sample all
得点 / 配点 0 / 0 1 / 1
結果
AC × 4
AC × 31
セット名 テストケース
sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
all sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
ケース名 結果 実行時間 メモリ
01-01.txt AC 1 ms 256 KiB
01-02.txt AC 1 ms 256 KiB
01-03.txt AC 1 ms 256 KiB
01-04.txt AC 1 ms 256 KiB
01-05.txt AC 1 ms 256 KiB
01-06.txt AC 1 ms 256 KiB
01-07.txt AC 1 ms 256 KiB
01-08.txt AC 1 ms 256 KiB
01-09.txt AC 1 ms 256 KiB
01-10.txt AC 1 ms 256 KiB
01-11.txt AC 1 ms 256 KiB
01-12.txt AC 1 ms 256 KiB
01-13.txt AC 1 ms 256 KiB
01-14.txt AC 1 ms 256 KiB
01-15.txt AC 1 ms 256 KiB
01-16.txt AC 1 ms 256 KiB
01-17.txt AC 1 ms 256 KiB
01-18.txt AC 1 ms 256 KiB
01-19.txt AC 1 ms 256 KiB
01-20.txt AC 1 ms 256 KiB
01-21.txt AC 1 ms 256 KiB
01-22.txt AC 1 ms 256 KiB
01-23.txt AC 1 ms 256 KiB
sample-01.txt AC 1 ms 256 KiB
sample-02.txt AC 1 ms 256 KiB
sample-03.txt AC 1 ms 256 KiB
sample-04.txt AC 1 ms 256 KiB