0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

E - Bichromization

https://atcoder.jp/contests/keyence2020/submissions/36537145
This commit is contained in:
Baoshuo Ren 2022-11-16 20:31:25 +08:00
parent 8392469474
commit f1ae598110
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
87 changed files with 331 additions and 0 deletions

View File

@ -0,0 +1,73 @@
#include <iostream>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5,
M = 2e5 + 5;
int n, m, a[N], ans[M];
std::vector<std::pair<int, int>> g[N];
char c[N];
std::queue<int> q;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1, u, v; i <= m; i++) {
cin >> u >> v;
g[u].emplace_back(v, i);
g[v].emplace_back(u, i);
if (a[u] == a[v] && !c[u] && !c[v]) {
c[u] = 'W';
c[v] = 'B';
q.emplace(u);
q.emplace(v);
ans[i] = a[u];
}
}
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto e : g[u]) {
int v = e.first,
id = e.second;
if (!c[v] && a[u] <= a[v]) {
c[v] = c[u] == 'W' ? 'B' : 'W';
ans[id] = a[v];
q.emplace(v);
}
}
}
if (std::count(c + 1, c + 1 + n, '\0')) {
cout << -1 << endl;
exit(0);
}
cout << c + 1 << endl;
for (int i = 1; i <= m; i++) {
cout << (ans[i] ? ans[i] : 1000000000) << endl;
}
return 0;
}

BIN
AtCoder/keyence2020/E/data/01-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/01-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/02-16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-08.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-08.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-09.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-09.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/03-10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/04-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/sample-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/sample-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/sample-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/sample-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/sample-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AtCoder/keyence2020/E/data/sample-03.out (Stored with Git LFS) Normal file

Binary file not shown.