結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー vjudge1
提出日時 2026-11-23 16:30:37
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 823µs
コード長 3,478 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,973 ms
コンパイル使用メモリ 254,472 KB
実行使用メモリ 9,916 KB
最終ジャッジ日時 2026-11-23 16:30:41
合計ジャッジ時間 3,739 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// Bismillah
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define nl cout << "\n";
#define YN(condition) cout << (condition ? "YES" : "NO")
#define yn(condition) cout << (condition ? "Yes" : "No")

#define int long long
#define lint __int128
#define ll long long
#define ld long double
#define pii pair<int, int>
const int inf = 1e17;
const int MOD = 1000000007;

#define ac(n) array<char, n>
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define vpi vector<pair<int, int>>
#define vvi vector<vector<int>>
#define mp map<int, int>
#define pq priority_queue<int>
#define pqmin priority_queue<int, vector<int>, greater<int>>
#define pqminpair priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>

#define f(i, s, e) for (int i = s; i < e; i++)
#define fn(i, s, e) for (int i = s; i >= e; i--)

#define pb push_back
#define pp pop_back
#define all(s) s.begin(), s.end()
#define sa(vec) sort(vec.begin(), vec.end())
#define sd(vec) sort(vec.begin(), vec.end(), [](int a, int b) { return a > b; })

template <typename T>
using ordered_set = tree<
    T,           // key type
    null_type,   // mapped type (null => set)
    less<T>,     // ordering
    rb_tree_tag, // red-black tree
    tree_order_statistics_node_update>;
// .find_by_order(k) returns iterator of kth smallest element (0 based)
// .order_of_key(k) returns number of elements < x

template <typename A, typename B>
istream &operator>>(istream &in, pair<A, B> &p)
{
    in >> p.first >> p.second;
    return in;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v)
{
    for (auto &x : v)
        in >> x;
    return in;
}
template <typename A, typename B>
istream &operator>>(istream &in, vector<pair<A, B>> &vp)
{
    for (auto &p : vp)
        in >> p.first >> p.second;
    return in;
}
template <typename A, typename B>
ostream &operator<<(ostream &out, const pair<A, B> &p)
{
    out << p.first << " " << p.second;
    return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    for (auto &x : v)
        out << x << " ";
    return out;
}
template <typename A, typename B>
ostream &operator<<(ostream &out, const vector<pair<A, B>> &vp)
{
    for (auto &p : vp)
        out << p.first << " " << p.second << "\n";
    return out;
}

#define fastnuces            \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);             \
    int t = 1;
int test = 0;
void solve()
{
    int x, y, l;
    cin >> x >> y >> l;
    int ans = 0;
    if (x == 0 and y == 0)
    {
        cout << 0;
        return;
    }
    if (x == 0)
    {
        if (y < 0)
            ans += 2;
    }
    else if (y == 0)
    {
        ans++;
    }
    else
    {
        if (x > 0 and y > 0)
        {
            ans++;
        }
        else if (x > 0 and y < 0)
        {
            ans += 2;
        }
        else if (x < 0 and y > 0)
        {
            ans++;
        }
        else if (x < 0 and y < 0)
        {
            ans += 2;
        }
    }
    ans += (abs(x) + l - 1) / l;
    ans += (abs(y) + l - 1) / l;
    cout << ans;
}
signed main()
{
    fastnuces;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //  cin >> t;
    while (t--)
    {
        test++;
        solve();
        nl
    }
    return 0;
}
0