QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#123185 | #89. Restore Array | somethingnew | 0 | 97ms | 3744kb | C++20 | 1.7kb | 2023-07-11 20:40:56 | 2023-07-11 20:40:58 |
Judging History
answer
// ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
// ➡ @roadfromroi ⬅
// ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#define all(x) x.begin(), x.end()
using namespace std;
int lgr[5000][5000];
int rgr[5000][5000];
int prfsm1[5001];
int prfempt[5001];
void solve() {
int n, m;
cin >> n >> m;
vector<int> res(n+1, n + 2);
res[0] = 0;
vector<array<int, 3>> edgs;
for (int i = 0; i < n; ++i) {
edgs.push_back({i, i + 1, 1});
edgs.push_back({i + 1, i, 0});
}
for (int i = 0; i < m; ++i) {
int a, b, c, d;
cin >> a >> b >> c >> d;
if (d == 1) {
edgs.push_back({b+1, a, b - a + 1 - c + 1});
//lgr[a][b] = max(lgr[a][b], b - a + 1 - c + 1);
} else {
edgs.push_back({a, b+1, b - a + 1 - c});
//rgr[a][b] = min(rgr[a][b], b - a + 1 - c);
}
}
for (int i = 0; i < n; ++i) {
for (auto [a, b, c] : edgs) {
res[b] = min(res[b], res[a] + c);
}
}
bool ok = 1;
for (auto [a, b, c] : edgs) {
if (res[b] != min(res[b], res[a] + c))
ok = 0;
res[b] = min(res[b], res[a] + c);
}
if (ok == 0) {
cout << "-1\n";return;
}
for (int i = 0; i < n; ++i) {
cout << res[i + 1] - res[i] << ' ';
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t = 1;
while (t--) {
solve();
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 1ms
memory: 3348kb
input:
8 13 0 1 2 1 3 5 1 1 5 7 2 1 0 2 2 0 2 5 3 1 3 7 4 1 2 2 1 0 0 1 1 0 2 7 5 1 2 4 1 0 0 4 2 0 4 5 2 1 1 2 1 0
output:
1 0 0 1 1 1 1 1
result:
ok your plan is correct!
Test #2:
score: 0
Accepted
time: 1ms
memory: 3388kb
input:
7 10 0 3 4 1 2 3 1 0 1 2 2 0 1 3 2 0 0 5 3 0 0 5 5 1 1 4 2 0 2 4 1 0 1 3 3 0 3 5 2 0
output:
1 0 0 0 1 0 1
result:
ok your plan is correct!
Test #3:
score: -7
Wrong Answer
time: 0ms
memory: 3404kb
input:
18 190 12 15 3 0 12 12 1 0 11 11 1 0 5 17 3 0 3 4 1 0 1 14 7 0 15 16 1 0 2 13 10 0 4 11 1 0 0 12 2 0 2 10 6 0 6 6 1 0 12 12 1 0 5 8 1 0 2 7 3 0 13 15 2 0 5 14 6 0 14 14 1 0 9 11 1 0 5 17 13 1 6 17 5 0 0 6 1 0 0 9 3 0 10 14 3 0 5 12 1 0 0 17 16 0 0 15 7 0 1 14 8 0 14 16 3 1 1 3 3 1 4 16 11 0 0 16 4 0...
output:
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
result:
wrong answer your plan does not meet the constraint #30
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 13
Accepted
time: 94ms
memory: 3684kb
input:
4992 9040 331 4442 1 0 3489 4173 1 0 393 4420 1 0 1324 2666 1 0 1317 4131 1 0 399 3010 1 0 1843 4154 1 0 1119 4876 1 0 4216 4980 1 0 2003 4370 1 0 769 1927 1 0 934 3414 1 0 2072 2507 1 0 215 3526 1 0 1493 4107 1 0 539 1643 1 0 2783 4338 1 0 967 1190 1 0 1374 2868 1 0 34 1378 1 0 71 1418 1 0 2120 223...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 ...
result:
ok your plan is correct!
Test #12:
score: 0
Accepted
time: 97ms
memory: 3744kb
input:
4952 9496 4222 4300 1 0 2892 4392 1 0 4158 4700 1 0 2720 3468 1 0 3002 3114 1 0 1010 4681 1 0 629 4392 1 0 734 2030 1 0 1024 2836 1 0 299 2880 1 0 3728 4858 1 0 1616 2861 1 0 2716 2938 1 0 1265 2892 1 0 1695 1778 1 0 1414 2231 1 0 47 4835 1 0 1554 3489 1 0 2591 3178 1 0 2424 4665 1 0 1089 2460 1 0 2...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 ...
result:
ok your plan is correct!
Test #13:
score: 0
Accepted
time: 96ms
memory: 3720kb
input:
4995 9192 257 4428 1 0 2504 2636 1 0 208 4875 1 0 1462 2898 1 0 1000 2298 1 0 4596 4745 1 0 614 4072 1 0 1425 1941 1 0 2378 4165 1 0 496 1556 1 0 255 4838 1 0 76 2176 1 0 349 3143 1 0 1325 4409 1 0 854 3653 1 0 4656 4945 1 0 2957 4396 1 0 784 4891 1 0 4488 4917 1 0 1721 4188 1 0 231 4748 1 0 282 332...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok your plan is correct!
Test #14:
score: -13
Wrong Answer
time: 94ms
memory: 3588kb
input:
4938 9603 2957 4666 1 0 2348 3586 1 0 3501 3789 1 0 2741 4713 1 0 1217 1254 1 0 192 2857 1 0 1242 2716 1 0 2315 4140 1 0 2464 2912 1 0 189 2590 1 0 4150 4701 1 0 3604 3942 1 0 2491 2801 1 0 1009 2819 1 0 1508 3589 1 0 88 4021 1 0 86 487 1 0 2857 4336 1 0 1738 4473 1 0 1385 1969 1 0 3187 4675 1 0 753...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer your plan does not meet the constraint #767
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%