結果
問題 | No.953 席 |
ユーザー | FF256grhy |
提出日時 | 2019-12-16 02:49:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,569 bytes |
コンパイル時間 | 1,991 ms |
コンパイル使用メモリ | 184,212 KB |
実行使用メモリ | 9,088 KB |
最終ジャッジ日時 | 2024-07-02 19:01:56 |
合計ジャッジ時間 | 10,637 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 250 ms
5,376 KB |
testcase_03 | AC | 254 ms
5,376 KB |
testcase_04 | AC | 250 ms
5,376 KB |
testcase_05 | AC | 247 ms
5,376 KB |
testcase_06 | AC | 254 ms
5,376 KB |
testcase_07 | AC | 287 ms
8,576 KB |
testcase_08 | AC | 323 ms
7,412 KB |
testcase_09 | AC | 239 ms
9,088 KB |
testcase_10 | AC | 85 ms
5,376 KB |
testcase_11 | AC | 244 ms
6,396 KB |
testcase_12 | AC | 286 ms
5,632 KB |
testcase_13 | AC | 319 ms
7,176 KB |
testcase_14 | AC | 270 ms
5,376 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 260 ms
5,376 KB |
testcase_24 | WA | - |
testcase_25 | AC | 331 ms
7,164 KB |
testcase_26 | AC | 237 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); ++i) #define incII(i, l, r) for(int i = (l) ; i <= (r); ++i) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i) #define decII(i, l, r) for(int i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); }; auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); }; auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); }; auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); }; auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); }; auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); }; auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; }; LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); } LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } #define bit(b, i) (((b) >> (i)) & 1) #define SI(v) static_cast<int>(v.size()) #define RF(e, v) for(auto & e: v) #define until(e) while(! (e)) #define if_not(e) if(! (e)) #define ef else if #define UR assert(false) // ---- ---- #define GPQ priority_queue template<typename T> class LPQ : public GPQ<T, vector<T>, greater<T>> { }; int main() { int n; cin >> n; vector<int> pos(n), ord(n, -1); cin >> pos[0] >> pos[1]; pos[0]--; pos[1]--; ord[pos[0]] = 0; ord[pos[1]] = 1; incID(i, 2, n) { int x = pos[i - 1]; int y = pos[i - 2]; if(x < y) { x--; y++; } else { y--; x++; } pos[i] = (inID(y, 0, n) && ord[y] == -1 ? y : x); ord[pos[i]] = i; } vector<int> state(n, 0); set<pair<int, int>> SEAT; inc(i, n) { SEAT.emplace(0, i); } LPQ<pair<LL, int>> out; auto check = [&](int pos) { if_not(inID(pos, 0, n)) { return; } SEAT.erase({ 0, ord[pos] }); SEAT.erase({ 1, ord[pos] }); if(state[pos] == 2) { return; } bool x = (pos == 0 || state[pos - 1] <= 1); bool y = (pos == n - 1 || state[pos + 1] <= 1); state[pos] = (x && y ? 0 : 1); SEAT.emplace(state[pos], ord[pos]); }; auto IN = [&](int pos) { // cout << "IN: " << pos + 1 << endl; assert(state[pos] <= 1); state[pos] = 2; check(pos ); check(pos - 1); check(pos + 1); }; auto OUT = [&](int pos) { // cout << "OUT: " << pos + 1 << endl; assert(state[pos] == 2); state[pos] = 0; check(pos ); check(pos - 1); check(pos + 1); }; auto print = [&]() { inc(i, n) { cout << "OoX"[state[i]]; } cout << endl; }; LL time = 0; int q; cin >> q; inc(i, q) { LL a, b; cin >> a >> b; // setmax(time, a); time = a; // test { while(SI(out) > 0 && out.top().FI <= time) { OUT(out.top().SE); out.pop(); } } if(SI(SEAT) == 0) { time = out.top().FI; while(SI(out) > 0 && out.top().FI == time) { OUT(out.top().SE); out.pop(); } } // cout << "t = " << time << endl; // print(); int p = pos[SEAT.begin() -> SE]; IN(p); out.emplace(time + b, p); // print(); cout << p + 1 << "\n"; // cout << endl; } return 0; }