Submission #258706

# Submission time Handle Problem Language Result Execution time Memory
258706 2020-08-06T11:52:50 Z dolphingarlic Tram (CEOI13_tram) C++14
0 / 100
19 ms 932 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll n, m;
bool used[150001][3];
pair<ll, ll> pos[30001];
set<ll> hmmst;

ll dist(pair<ll, ll> A, pair<ll, ll> B) {
    return B.first - A.first * B.first - A.first + B.second -
           A.second * B.second - A.second;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    hmmst.insert(1);
    hmmst.insert(n);
    for (int i = 1; i <= m; i++) {
        char c;
        cin >> c;
        if (c == 'E') {
            ll best_dist = 0;
            pair<ll, ll> best_pos;
            for (auto it = next(hmmst.begin()); it != hmmst.end(); it++) {
                ll mid1 = (*it + *prev(it)) / 2,
                   mid2 = (*it + *prev(it) + 1) / 2;
                vector<pair<ll, ll>> cand = {
                    {*prev(it), 1}, {*prev(it), 2}, {mid1, 1}, {mid1, 2},
                    {mid2, 1},      {mid2, 2},      {*it, 1},  {*it, 2}};
                for (pair<ll, ll> j : cand) {
                    if (!used[j.first][j.second]) {
                        ll d = LLONG_MAX;
                        for (pair<ll, ll> k : cand) {
                            if (used[k.first][k.second]) {
                                d = min(d, dist(j, k));
                            }
                        }
                        if (d > best_dist &&
                            (d != LLONG_MAX || hmmst.size() == 2)) {
                            best_dist = d;
                            best_pos = j;
                        }
                    }
                }
            }
            pos[i] = best_pos;
            used[pos[i].first][pos[i].second] = true;
            hmmst.insert(pos[i].first);
            cout << pos[i].first << ' ' << pos[i].second << '\n';
        } else {
            ll idx;
            cin >> idx;
            used[pos[idx].first][pos[idx].second] = false;
            if (pos[idx].first != 1 && pos[idx].first != n &&
                !(used[pos[idx].first][0] || used[pos[idx].first][1]))
                hmmst.erase(pos[idx].first);
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 876 KB Output isn't correct
2 Halted 0 ms 0 KB -