QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#587995#5653. Library gameNananiRE 1ms5668kbC++202.3kb2024-09-24 23:23:192024-09-24 23:23:19

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 23:23:19]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5668kb
  • [2024-09-24 23:23:19]
  • 提交

answer

//by 72
#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define Fd(i, a, b) for(int i = a; i >= b; i --)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define int long long
using namespace std;

const int mod = 998244353;
const int N = 2e5 + 10;
const int inf = 1e18;
typedef array<int, 3> a3; 
typedef long long ll;

int n, m, x[N], vst[N];

void sol() {
    cin >> n >> m;
    F(i, 1, n) cin >> x[i];
    sort(x + 1, x + 1 + n);
    reverse(x + 1, x + 1 + n);
    int ok = -1;
    F(i, 1, n) {
        // cout << (m - i) / i + 1 << " " << x[i] << endl;
        if((m - i) / i + 1 < x[i]) ok = i;
    }

    // cout << ok << "!!\n";
    set<pii> s;
    s.insert({m, 1});
    if(ok == -1) {
        cout << "Alessia" << endl;
        cout << flush;
        F(i, 1, n) {
            pii now = {-1, -1};
            for(auto [len, l] : s) {
                if(len >= x[i]) {
                    cout << x[i] << " " << l << endl;
                    cout << flush;
                    int y; cin >> y;
                    int r = l + len - 1;
                    s.erase(s.find({len, l}));
                    if(l <= y - 1) s.insert({y - l, l});
                    if(y + 1 <= r) s.insert({r - y, y + 1});
                    break; 
                }
            }
            // assert(ok);
        }
    } else {
        cout << "Bernardo" << endl;
        vector<int> qaq;
        for(int i = x[ok]; i <= m; i += x[ok]) qaq.push_back(i);
        // cout << x[ok] << "!!\n";
        // for(auto x : qaq) cout << x << " "; cout << endl;
        F(i, 1, n) {
            int len, l; cin >> len >> l;
            int r = l + len - 1;
            bool qsy = false;
            F(j, l, r) {
                if(vst[j]) {
                    cout << j << endl;
                    qsy = 1;
                    break;
                }
            }
            if(qsy) continue;
            for(auto x : qaq) if(x >= l && x <= r) {
                cout << x << endl;
                qsy = true;
                break;
            } 
            assert(qsy);
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    F(i, 1, t) sol();
    return 0;
}
//sldl
/*
5 14
3 7 2 3 10
10 1
7 4
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5668kb

input:

5 14
3 7 2 3 10
7
14
2
4
6

output:

Alessia
10 1
7 8
3 1
3 3
2 5

result:

ok Contestant won the game

Test #2:

score: -100
Runtime Error

input:

4 10
4 1 6 4
6 1
4 5
4 6
1 9

output:

Bernardo
4
8
8

result: