QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214135 | #5669. Traveling in Jade City | Jeffrey# | WA | 492ms | 38640kb | C++14 | 3.8kb | 2023-10-14 17:26:40 | 2023-10-14 17:26:40 |
Judging History
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 (y <= 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: 6ms
memory: 15196kb
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: 15136kb
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: 492ms
memory: 38640kb
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 -77733600 -129670600 302943400 impossible impossible impossible impossible 338930200 377541000 369719200 320622400 -8839600 impossible -1192000 impossible 320440000 349170800 -11420600 393149800 -62578200 impossible -164659600 impossible -62216200 impossible impossible impossible impossibl...
result:
wrong answer 2nd lines differ - expected: '122264600', found: '-77733600'