0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 23:08:47 +00:00

#1698. 【2022.10.27 联考】传送

https://sjzezoj.com/submission/62433
This commit is contained in:
Baoshuo Ren 2022-10-27 21:44:19 +08:00
parent dcc6d24eda
commit 8dee4da809
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
76 changed files with 295 additions and 0 deletions

70
S2OJ/1698/1698.cpp Normal file
View File

@ -0,0 +1,70 @@
#include <iostream>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int t, n, m, q, cnt, block[N], color[N];
std::vector<int> g[N];
bool flag[N];
void dfs(int u, int f) {
block[u] = cnt;
for (int v : g[u]) {
if (color[v] != -1 && color[u] == color[v]) {
flag[cnt] = true;
} else if (color[v] == -1) {
color[v] = color[u] ^ 1;
dfs(v, u);
}
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t >> n >> m;
for (int i = 1, u, v; i <= m; i++) {
cin >> u >> v;
g[u].emplace_back(v);
g[v].emplace_back(u);
}
std::fill_n(color, N, -1);
for (int i = 1; i <= n; i++) {
if (color[i] == -1) {
cnt++;
color[i] = 0;
dfs(i, 0);
}
}
cin >> q;
while (q--) {
int s, t;
cin >> s >> t;
if (s == t) {
cout << 0 << endl;
} else if (block[s] != block[t]) {
cout << -1 << endl;
} else if (flag[block[s]] || color[s] != color[t]) {
cout << 1 << endl;
} else {
cout << 2 << endl;
}
}
return 0;
}

BIN
S2OJ/1698/data/ex_teleport1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/ex_teleport4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport13.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport14.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport15.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport16.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport17.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport18.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport19.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport20.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport21.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport22.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport23.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport24.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport25.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport26.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport27.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport28.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport29.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport30.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport31.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport31.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport32.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport32.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport33.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport33.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1698/data/teleport9.in (Stored with Git LFS) Normal file

Binary file not shown.