提出 #53885209


ソースコード 拡げる

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ah_yeah                                                                                    \
    ios_base::sync_with_stdio(0);                                                                  \
    cin.tie(0);
#define all(x) (x).begin(), (x).end()
#define ss second
#define ff first
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define REPL(n) for (int i = 0; i < n; i++)
#define nline '\n'

//  input
template <typename T> ostream &operator<<(ostream &s, const vector<T> &self) {
    for (auto &e : self) {
        s << e << ' ';
    }
    return s;
}
template <typename T> istream &operator>>(istream &s, vector<T> &self) {
    for (size_t i = 0; i < self.size(); ++i) {
        s >> self[i];
    }
    return s;
}

#ifndef ONLINE_JUDGE
#define dbg(x)                                                                                     \
    cerr << #x << "\n";                                                                            \
    _print(x);                                                                                     \
    cerr << endl;
#else
#define dbg(x)
#endif

// debugging
//*********************************************************************
void _print(pair<int, int> p) { cerr << "[" << p.ff << "," << p.ss << "]"; }
void _print(int x) { cerr << x; }
void _print(ll x) { cerr << x; }
void _print(string &x) { cerr << x; }
void _print(char x) { cerr << x; }
template <class T> void _print(vector<T> &v) {
    cerr << "[ ";
    for (T i : v) {
        _print(i);
        cerr << " ";
    }
    cerr << "]\n";
}
template <class T> void _print(set<T> &pt) {
    cerr << "[ ";
    for (T i : pt) {
        _print(i);
        cerr << " ";
    }
    cerr << "]\n";
}
template <class T> void _print(multiset<T> &pt) {
    cerr << "[ ";
    for (T i : pt) {
        _print(i);
        cerr << " ";
    }
    cerr << "]\n";
}

template <class T> void _print(map<T, T> &pt) {
    for (auto i : pt) {
        _print(i.first);
        cerr << "-> ";
        _print(i.second);
        cerr << endl;
    }
}
//*********************************************************************

// useful functions....
//*********************************************************************
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

// might overflow for large numbers....
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll ceil(ll a, ll b) { return a % b == 0 ? a / b : a / b + 1; }
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b != 0) {
        if (b % 2) {
            res *= a;
        }
        a *= a;
        b /= 2;
    }
    return res;
}
ll binmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
// if m is prime
ll modinv(ll a, ll m) { return binmod(a, m - 2, m); }
int popCount(int x) { return __builtin_popcount(x); }
int popCountLL(ll x) { return __builtin_popcountll(x); }
bool setBit(ll num, int bit) { return num & (1LL << bit); }
//*********************************************************************

int N, L, R;
ll dp[1 << 19];

ll f(ll curr) {
    if (curr >= R) {
        return dp[curr] = 0;
    }
    if (dp[curr] != -1) {
        return dp[curr];
    }
    ll ans = LLONG_MAX;
    for (ll i = 0; i <= 18; ++i) {
        if ((curr % (1LL << i)) == 0) {
            ll j = curr / (1 << i);
            ll rgt = (1LL << i) * (j + 1LL) - 1LL;
            if (rgt <= R) {
                ans = min(ans, 1 + f(rgt + 1));
            }
        }
    }

    return dp[curr] = ans;
}

void solve(int _) {
    cin >> N >> L >> R;
    memset(dp, -1, sizeof(dp));
    f(L);

    vector<pii> res;
    int curr = L;

    
    while (curr != R) {
        for (int j = curr + 1; j <= R; ++j) {
            if (dp[curr] - dp[j] == 1) {
                res.push_back({curr, (j == R ? R : j - 1)});
                curr = j;
                break;
            }
        }
    }
    int fans = 0;
    for (auto &m : res) {
        int diff = m.ss - m.ff + 1;
        int l = m.ff;
        int ct = 0;
        while (diff != 1) {
            diff /= 2;
            ct++;
        }
        int r = m.ss + 1;
        r /= (1 << ct);
        r--;
        cout << "? " << ct << " " << r << endl;
        int x;
        cin >> x;
        fans = (fans + x) % 100;
    }

    cout << "! " << fans << endl;
}

signed main() {
    ah_yeah;
    srand(time(nullptr));
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif

    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
    return 0;
}

提出情報

提出日時
問題 E - Guess the Sum
ユーザ prathik8794
言語 C++ 17 (gcc 12.2)
得点 0
コード長 5173 Byte
結果 WA
実行時間 54 ms
メモリ 24228 KiB

コンパイルエラー

Main.cpp: In function ‘void solve(int)’:
Main.cpp:174:13: warning: unused variable ‘l’ [-Wunused-variable]
  174 |         int l = m.ff;
      |             ^
Main.cpp:153:16: warning: unused parameter ‘_’ [-Wunused-parameter]
  153 | void solve(int _) {
      |            ~~~~^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 500
結果
AC × 1
AC × 6
WA × 32
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 4 ms 7596 KiB
01_random_00.txt WA 4 ms 7712 KiB
01_random_01.txt WA 4 ms 7732 KiB
01_random_02.txt WA 4 ms 7724 KiB
01_random_03.txt WA 4 ms 7596 KiB
01_random_04.txt WA 4 ms 7732 KiB
01_random_05.txt AC 4 ms 7668 KiB
01_random_06.txt WA 4 ms 7784 KiB
01_random_07.txt WA 4 ms 7664 KiB
01_random_08.txt WA 4 ms 7848 KiB
01_random_09.txt AC 4 ms 7628 KiB
01_random_10.txt WA 16 ms 11140 KiB
01_random_11.txt WA 5 ms 7836 KiB
01_random_12.txt WA 5 ms 7620 KiB
01_random_13.txt WA 13 ms 9328 KiB
01_random_14.txt WA 19 ms 8548 KiB
01_random_15.txt AC 37 ms 11872 KiB
01_random_16.txt WA 35 ms 10348 KiB
01_random_17.txt WA 48 ms 19648 KiB
01_random_18.txt WA 51 ms 22524 KiB
01_random_19.txt WA 49 ms 20516 KiB
01_random_20.txt WA 31 ms 7960 KiB
01_random_21.txt WA 46 ms 18672 KiB
01_random_22.txt WA 41 ms 15144 KiB
01_random_23.txt WA 39 ms 13128 KiB
01_random_24.txt WA 32 ms 8452 KiB
01_random_25.txt WA 48 ms 20476 KiB
01_random_26.txt WA 51 ms 22576 KiB
01_random_27.txt WA 49 ms 20792 KiB
01_random_28.txt WA 51 ms 21568 KiB
01_random_29.txt WA 51 ms 22508 KiB
01_random_30.txt WA 52 ms 23012 KiB
01_random_31.txt AC 54 ms 24228 KiB
01_random_32.txt WA 53 ms 23968 KiB
01_random_33.txt WA 31 ms 7732 KiB
01_random_34.txt WA 4 ms 7848 KiB
01_random_35.txt AC 4 ms 7732 KiB
01_random_36.txt WA 4 ms 7736 KiB