QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214152#5669. Traveling in Jade CityJeffrey#WA 429ms38984kbC++143.8kb2023-10-14 17:32:582023-10-14 17:32:59

Judging History

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

  • [2023-10-14 17:32:59]
  • 评测
  • 测评结果:WA
  • 用时:429ms
  • 内存:38984kb
  • [2023-10-14 17:32:58]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, k, m, q, u, v, c[3][1000006] = {};
    set<int> s[3] = {};
    cin >> n >> k >> m >> q;
    for (int i = 1; i < k; i++) cin >> c[0][i];
    for (int i = k; i <= n; i++) cin >> c[1][i];
    for (int i = 0; i <= m; i++) cin >> c[2][i];
    for (int i = 1; i < k; i++) c[0][i] += c[0][i - 1];
    for (int i = k; i <= n; i++) c[1][i] += c[1][i - 1];
    for (int i = 1; i <= m; i++) c[2][i] += c[2][i - 1];
    while (q--) {
        char o;
        cin >> o;
        if (o == 'c') {
            cin >> u;
            if (u < k) {
                if (s[0].find(u) == s[0].end()) s[0].insert(u);
                else s[0].erase(u);
            } else {
                if (s[1].find(u) == s[1].end()) s[1].insert(u);
                else s[1].erase(u);
            }
        } else if (o == 'x') {
            cin >> u;
            if (s[2].find(u) == s[2].end()) s[2].insert(u);
            else s[2].erase(u);
        } else {
            int z = mod;
            cin >> u >> v;
            if (u > v) swap(u, v);
            int x = 0, y = 0;
            if (u < k) x = 0;
            else if (u <= n) x = 1;
            else x = 2;
            if (v < k) y = 0;
            else if (v <= n) y = 1;
            else y = 2;
            int d[7] = {};
            for (int i = 0; i < 7; i++) d[i] = 5e8;
            if (s[0].empty()) d[0] = c[0][k - 1];
            if (s[1].empty()) d[1] = c[1][n];
            if (s[2].empty()) d[2] = c[2][m];
            if (x == 0) {
                if (s[0].empty() || *s[0].begin() >= u) d[3] = c[0][u - 1];
                if (s[0].empty() || *s[0].rbegin() < u) d[4] = c[0][k - 1] - c[0][u - 1];
            } else if (x == 1) {
                if (s[1].empty() || *s[1].rbegin() < u) d[3] = c[1][n] - c[1][u - 1];
                if (s[1].empty() || *s[1].begin() >= u) d[4] = c[1][u - 1];
            } else {
                if (s[2].empty() || *s[2].begin() >= u - n) d[3] = c[2][u - n - 1];
                if (s[2].empty() || *s[2].rbegin() < u - n) d[4] = c[2][m] - c[2][u - n - 1];
            }
            if (y == 0) {
                if (s[0].empty() || *s[0].begin() >= v) d[5] = c[0][v - 1];
                if (s[0].empty() || *s[0].rbegin() < v) d[6] = c[0][k - 1] - c[0][v - 1];
            } else if (y == 1) {
                if (s[1].empty() || *s[1].rbegin() < v) d[5] = c[1][n] - c[1][v - 1];
                if (s[1].empty() || *s[1].begin() >= v) d[6] = c[1][v - 1];
            } else {
                if (s[2].empty() || *s[2].begin() >= v - n) d[5] = c[2][v - n - 1];
                if (s[2].empty() || *s[2].rbegin() < v - n) d[6] = c[2][m] - c[2][v - n - 1];
            }
            //for (int i = 0; i < 7; i++) cout << d[i] << ' ';
            if (x == y) {
                if (x == 0) {
                    if (s[0].empty() || *s[0].lower_bound(u) >= v) z = min(z, c[0][v - 1] - c[0][u]);
                } else if (x == 1) {
                    if (s[1].empty() || *s[1].lower_bound(u) >= v) z = min(z, c[1][v - 1] - c[0][u]);
                } else {
                    if (s[2].empty() || *s[2].lower_bound(u - n) >= v - n) z = min(z, c[2][v - n - 1] - c[2][u - n - 1]);
                }
            }
            z = min(z, d[3] + d[5]);
            z = min(z, d[4] + d[6]);
            z = min(z, d[3] + min({d[0], d[1], d[2]}) + d[6]);
            z = min(z, d[4] + min({d[0], d[1], d[2]}) + d[5]);
            if (z > 4e8) cout << "impossible\n";
            else cout << z << '\n';
        }
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 15284kb

input:

4 3 1 9
2 3 8 4
1 1
q 3 4
x 0
q 3 4
c 3
q 3 4
c 1
q 3 4
x 0
q 3 4

output:

6
8
9
impossible
6

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 15356kb

input:

4 3 1 9
2 3 8 4
1 1
q 3 4
x 0
q 3 4
c 3
q 3 4
c 1
q 3 4
x 0
q 3 4

output:

6
8
9
impossible
6

result:

ok 5 lines

Test #3:

score: -100
Wrong Answer
time: 429ms
memory: 38984kb

input:

1000000 999999 1000000 1000000
200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 2...

output:

177406400
122264600
70328400
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
29295200
impossible
22163200
impossible
impossible
impossible
11422200
impossible
62579800
impossible
35339400
impossible
20157200
impossible
impossible
impossible
impossib...

result:

wrong answer 464th lines differ - expected: '637000', found: '636800'