QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#275344 | #6526. Canvas | ucup-team1321# | WA | 0ms | 3932kb | C++23 | 2.9kb | 2023-12-04 17:03:17 | 2023-12-04 17:03:18 |
Judging History
answer
#include <bits/stdc++.h>
#ifndef LOCAL
#define debug(...) 42
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
#define rep1(a) for (auto i = 0; i < a; i++)
#define rep2(i, a) for (auto i = 0; i < a; i++)
#define rep3(i, a, b) for (auto i = a; i < b; i++)
#define rep4(i, a, b, c) for (auto i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define pb emplace_back
using namespace std;
template <typename T, typename T2> void cmin(T &x, const T2 &y) {
x = x < y ? x : y;
}
template <typename T, typename T2> void cmax(T &x, const T2 &y) {
x = x > y ? x : y;
}
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
mt19937 rng(time(NULL));
const int inf = 1000000000;
const ll lnf = 1000000000000000000;
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
void solve() {
int n, m;
cin >> n >> m;
vc<array<int, 4>> op(m);
vi a11, a22;
vi a12, a21;
rep(i, m) {
int l, x, r, y;
cin >> l >> x >> r >> y;
--l;
--r;
op[i] = array<int, 4>{l, x, r, y};
if (x == 1 && y == 1)
a11.pb(i);
if (x == 2 && y == 2)
a22.pb(i);
if (x == 1 && y == 2)
a12.pb(i);
if (x == 2 && y == 1)
a21.pb(i);
}
sort(all(a12), [&](int x, int y) { return op[x][2] > op[y][2]; });
sort(all(a21), [&](int x, int y) { return op[x][0] < op[y][0]; });
auto get = [&](vi p) {
vi a(n);
for (auto i : p) {
auto [l, x, r, y] = op[i];
a[l] = x;
a[r] = y;
}
return accumulate(all(a), 0);
};
int ans1;
vi p;
p.clear();
p.insert(p.end(), all(a11));
p.insert(p.end(), all(a21));
p.insert(p.end(), all(a12));
p.insert(p.end(), all(a22));
ans1 = get(p);
int ans2;
p.clear();
p.insert(p.end(), all(a11));
p.insert(p.end(), all(a12));
p.insert(p.end(), all(a21));
p.insert(p.end(), all(a22));
ans2 = get(p);
if (ans1 > ans2) {
p.clear();
p.insert(p.end(), all(a11));
p.insert(p.end(), all(a21));
p.insert(p.end(), all(a12));
p.insert(p.end(), all(a22));
cout << ans1 << "\n";
for (int i : p) {
cout << i + 1 << " ";
}
cout << "\n";
} else {
p.clear();
p.insert(p.end(), all(a11));
p.insert(p.end(), all(a12));
p.insert(p.end(), all(a21));
p.insert(p.end(), all(a22));
cout << ans2 << "\n";
for (int i : p) {
cout << i + 1 << " ";
}
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
input:
2 4 4 1 1 2 2 3 2 4 1 1 2 3 2 2 1 4 1 4 2 3 2 4 1 1 2 3 1
output:
7 4 1 2 3 5 2 1
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3932kb
input:
1 10 13 1 1 2 2 2 1 3 2 1 2 3 1 3 1 4 2 4 1 5 2 5 1 6 2 4 2 6 1 7 1 8 2 8 1 9 2 7 2 9 1 5 2 9 1 8 2 10 2 1 1 10 1
output:
18 13 3 7 11 10 9 8 6 5 4 2 1 12
result:
wrong answer Jury has better answer. Participant 18, jury 19 (test case 1)