QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#734787 | #4892. 序列 | NineSuns | 0 | 12ms | 46908kb | C++14 | 2.9kb | 2024-11-11 15:07:36 | 2024-11-11 15:07:36 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2e5+5;
int n, m, a[N], b[N], c[N], d[N], p[4], dfn[N*4], low[N*4], sid[N*4], sc, dt, stk[N*4], ed, istk[N*4], mk[N*4], f[N];
vector <int> v[N], e[N*4];
map <int, int> id[N];
void tarjan (int p) {
dfn[p] = low[p] = ++dt;
istk[p] = 1; stk[++ed] = p;
for (int i : e[p]) {
if (!dfn[i]) {
tarjan(i); low[p] = min(low[p], low[i]);
}
else if (istk[i]) low[p] = min(low[p], dfn[i]);
}
if (dfn[p] == low[p]) {
int x; ++sc;
do {
x = stk[ed--]; istk[x] = 0;
sid[x] = sc;
} while (x^p);
}
}
int main () {
cin >> n >> m;
for (int i = 1;i <= m;i++) {
int x, y, z, k;
cin >> x >> y >> z >> k;
a[i] = x; b[i] = y; c[i] = z; d[i] = k;
v[x].pb(k); v[y].pb(k); v[z].pb(k);
}
int S = 0;
for (int i = 1;i <= n;i++) v[i].pb(0), v[i].pb(1e9+1);
for (int i = 1;i <= n;i++) {
sort(v[i].begin(), v[i].end());
v[i].resize(unique(v[i].begin(), v[i].end())-v[i].begin());
for (int j : v[i]) id[i][j] = ++S; //, cout << i << " " << j << " " << S << endl;
}
// cout << endl;
for (int i = 1;i <= n;i++) {
for (int j : v[i]) {
if (j <= 1e9) e[id[i][j]].pb(id[i][j]+1);
}
for (int j : v[i]) {
if (j > 0) e[id[i][j]+S].pb(id[i][j]+S-1);
}
}
for (int i = 1;i <= m;i++) {
p[0] = a[i]; p[1] = b[i]; p[2] = c[i];
sort(p, p+3);
do {
// cout << p[0] << " -> " << p[1] << " " << d[i] << endl;
e[id[p[0]][d[i]]-1].pb(id[p[1]][d[i]]+S);
// e[id[p[0]][d[i]]-1].pb(id[p[2]][d[i]]+S);
e[id[p[0]][d[i]]+1+S].pb(id[p[1]][d[i]]);
// e[id[p[0]][d[i]]+1+S].pb(id[p[2]][d[i]]);
// cout << id[p[0]][d[i]]-1 << " " << id[p[1]][d[i]]+S << endl;
// cout << id[p[0]][d[i]]+1+S << " " << id[p[1]][d[i]] << endl;
} while (next_permutation(p, p+3));
}
for (int i = 1;i <= S+S;i++) if (!dfn[i]) tarjan(i);
for (int i = 1;i <= n;i++) {
for (int j : v[i]) {
if (j <= 1e9) {
if (sid[id[i][j]] == sid[id[i][j]+1+S]) {
cout << "NO"; return 0;
}
}
}
}
for (int i = 1;i <= sc;i++) {
}
// for (int i = 1;i <= S*2;i++) cout << sid[i] << " "; cout << endl;
cout << "YES\n";
for (int i = 1;i <= n;i++) {
int l = 1, r = 1e9;
for (int j : v[i]) {
if (sid[id[i][j]] >= sid[id[i][j]+S]) {
l = j;
}
}
for (int J = v[i].size()-1; ~J; J--) {
int j = v[i][J];
if (sid[id[i][j]] <= sid[id[i][j]+S]) {
r = j;
}
}
l = max(l, 1); r = min(r, (int)1e9);
l = min(l, (int)1e9); r = max(r, 1);
// continue;
if (l == r) cout << l << " ";
else {
if (sid[id[i][l]+S] < sid[id[i][r]]) cout << l << " ";
else cout << r << " ";
}
// for (int j : v[i]) {
// cout << sid[id[i][j]] << " " << sid[id[i][j]+S] << " " << j << endl;
// }
// cout << l << " " << r << endl;
// cout << endl;
// cout << max(1, min(k, (int)1e9)) << " ";
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 46388kb
input:
10 10 6 3 10 133562624 8 7 6 685486592 4 2 7 332482851 10 8 9 211550017 2 10 1 165556251 10 8 5 211550017 6 8 2 332482851 4 9 2 332482851 8 1 4 193658790 9 6 10 728674154
output:
YES 165556251 165556251 1 193658790 1000000000 728674154 685486592 211550017 1000000000 133562624
result:
wrong answer the 3-th condition is not satisfied
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 12ms
memory: 46908kb
input:
40 9880 4 19 31 610502845 10 19 33 190412843 21 24 39 649028784 16 22 40 569593239 5 9 37 550862419 11 23 40 654613112 6 18 23 492267246 22 23 30 538715841 6 16 24 407919735 5 16 18 388907784 2 16 18 388907784 21 24 28 281403057 7 12 27 451830401 3 11 16 508407438 15 33 36 561955959 6 23 29 70605893...
output:
YES 877488996 197498120 508407438 610502845 209356929 706058934 655952999 624132238 550862419 1 654613112 72694954 399757770 396827347 561955959 407919735 779328631 388907784 190412843 657895429 832003778 569593239 492267246 1 718125822 812463588 451830401 281403057 1000000000 538715841 664852212 14...
result:
wrong answer the 56-th condition is not satisfied
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%