Submission #258634

# Submission time Handle Problem Language Result Execution time Memory
258634 2020-08-06T09:37:12 Z dolphingarlic Tram (CEOI13_tram) C++14
25 / 100
1000 ms 424 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

pair<int, int> pos[100001];
set<pair<int, int>> active;

inline ll sq(int x) { return ll(x) * ll(x); }

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int cnt = 1; cnt <= m; cnt++) {
        char c;
        cin >> c;
        if (c == 'E') {
            if (!active.size()) pos[cnt] = {1, 1};
            else {
                pair<ll, pair<int, int>> best;
                for (int i = 1; i <= n; i++) {
                    for (int j = 1; j < 3; j++) {
                        ll dist = LLONG_MAX;
                        for (pair<int, int> k : active) {
                            dist = min(dist, sq(k.first - i) + sq(k.second - j));
                        }
                        if (dist > best.first) best = {dist, {i, j}};
                    }
                }
                pos[cnt] = best.second;
            }
            active.insert(pos[cnt]);
            cout << pos[cnt].first << ' ' << pos[cnt].second << '\n';
        } else {
            int i;
            cin >> i;
            active.erase(pos[i]);
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -