QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#629925 | #3563. Treatment Project | Dimash# | 0 | 30ms | 4616kb | C++23 | 2.1kb | 2024-10-11 15:34:43 | 2024-10-11 15:34:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 12, MOD = (int)1e9 + 7;
const ll inf = 1e18;
ll res = inf;
int n, m;
bool ok(vector<array<int, 4>> &x) {
if(x.empty()) return false;
int s = (int)x.size(), f = x.back()[0];
vector<array<int, 3>> otr;
vector<pair<int, int>> in;
for(int i = 0; i < s;) {
int j = i + 1;
while(j < s && x[j][0] == x[i][0]) {
j++;
}
vector<pair<int, int>> ff;
int mx = -2;
for(int k = i; k < j; ) {
int nx = k + 1;
int mx = x[k][2];
while(nx < j && mx >= x[nx][1] - 1) {
mx = max(mx, x[nx][2]);
nx++;
}
ff.push_back({x[k][1], mx});
k = nx;
}
for(auto [l, r]:ff) {
int del = (f - x[i][0]);
if(l > 1) {
l += del;
}
if(r < n) {
r -= del;
}
if(l <= r) {
in.push_back({l, r});
}
}
i = j;
}
sort(in.begin(), in.end());
int mx = 0;
for(auto [l, r]:in) {
if(l > mx + 1) {
return false;
}
mx = max(mx, r);
}
if(mx < n) return false;
return true;
}
vector<array<int, 4>> a;
void test() {
cin >> n >> m;
a.resize(m);
for(int i = 0; i < m; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
}
sort(a.begin(), a.end());
for(int i = 0; i < (1 << m); i++) {
ll c = 0;
vector<array<int, 4>> x;
for(int j = 0; j < m; j++) {
if((i >> j) & 1) {
c += a[j][3];
x.push_back(a[j]);
}
}
if(ok(x)) {
res = min(res, c);
}
}
if(res == inf) {
res = -1;
}
cout << res << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 30ms
memory: 4616kb
input:
1000000000 100000 1 811370001 811380000 1000000000 1 413190001 413200000 1000000000 1 462480001 462490000 1000000000 1 384860001 384870000 1000000000 1 543220001 543230000 1000000000 1 766300001 766310000 1000000000 1 348890001 348900000 1000000000 1 996350001 996360000 1000000000 1 302700001 302710...
output:
-1
result:
wrong answer 1st lines differ - expected: '100000000000000', found: '-1'
Subtask #2:
score: 0
Wrong Answer
Test #19:
score: 5
Accepted
time: 1ms
memory: 3628kb
input:
1 1 1000000000 1 1 1000000000
output:
1000000000
result:
ok single line: '1000000000'
Test #20:
score: 5
Accepted
time: 19ms
memory: 3856kb
input:
1000000000 16 6 2 2 1 4 999999997 999999999 4 2 999999997 1000000000 2 3 1 4 3 3 999999997 1000000000 3 5 999999998 999999999 3 6 999999999 999999999 1 2 1 4 2 6 3 999999998 1 999999987 1 1000000000 10 999999986 1 1000000000 10 999999985 1 1000000000 10 4 2 4 4 5 2 3 3 1 999999997 1000000000 1 1 1 4 1
output:
9
result:
ok single line: '9'
Test #21:
score: 5
Accepted
time: 23ms
memory: 3560kb
input:
1000000000 16 5 999999998 999999999 2 999999985 1 1000000000 8 5 2 3 3 2 1 4 2 4 2 4 3 6 3 999999998 1 1 999999997 1000000000 1 6 999999999 999999999 2 6 2 2 2 2 999999997 1000000000 2 3 999999997 1000000000 3 4 999999997 999999999 4 999999987 1 1000000000 10 1 1 4 1 999999986 1 1000000000 10 3 1 4 3
output:
8
result:
ok single line: '8'
Test #22:
score: 0
Wrong Answer
time: 21ms
memory: 3648kb
input:
1000000000 16 200000001 3 100000003 1000000000 1 1 100000001 1000000000 400000001 5 100000005 1000000000 1 900000000 1000000000 1000000000 500000001 899999995 999999995 1000000000 500000001 6 100000006 1000000000 600000001 899999994 999999994 1000000000 700000001 500000001 999999993 1000000000 40000...
output:
-1
result:
wrong answer 1st lines differ - expected: '16000000000', found: '-1'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%