# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
156100 |
2019-10-03T10:41:27 Z |
EntityIT |
전압 (JOI14_voltage) |
C++14 |
|
225 ms |
21240 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5, M = N << 1, inf = (int)1e9 + 123;
int n, m, disc[N], low[N], curDisc, ans, nBadEdge, nBadEdgeTree[N];
bool parity[N], vis[N];
vector<int> gr[N], graph[N];
struct Edge {
int u, v;
bool used;
Edge(int _u = 0, int _v = 0, bool _used = 0) : u(_u), v(_v), used(_used) {}
int oth(int vertex) { return u ^ v ^ vertex; }
} edge[M];
void dfs(int u, int p) {
disc[u] = low[u] = ++curDisc;
parity[u] = parity[p] ^ 1;
for (int id : gr[u]) if (!edge[id].used) {
edge[id].used = 1;
int v = edge[id].oth(u);
if (!disc[v]) {
graph[u].emplace_back(v);
dfs(v, u);
nBadEdgeTree[u] += nBadEdgeTree[v];
low[u] = min(low[u], low[v]);
}
else {
if (parity[u] == parity[v]) {
++nBadEdge;
++nBadEdgeTree[u]; --nBadEdgeTree[v];
}
else low[u] = min(low[u], disc[v]);
}
}
}
void solve(int u) {
vis[u] = 1;
for (int v : graph[u]) {
solve(v);
if (low[v] > disc[u] && nBadEdgeTree[v] == nBadEdge) ++ans;
}
}
int main() {
// freopen("input", "r", stdin);
scanf(" %d %d", &n, &m);
for (int i = 1; i <= m; ++i) {
int u, v; scanf(" %d %d", &u, &v);
edge[i] = Edge(u, v, 0);
gr[u].emplace_back(i);
gr[v].emplace_back(i);
}
for (int u = 1; u <= n; ++u) if (!disc[u]) dfs(u, 0);
if (nBadEdge == 1) ++ans;
for (int u = 1; u <= n; ++u) if (!vis[u]) solve(u);
printf("%d", ans);
return 0;
}
Compilation message
voltage.cpp: In function 'int main()':
voltage.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d %d", &n, &m);
~~~~~^~~~~~~~~~~~~~~~~~
voltage.cpp:51:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int u, v; scanf(" %d %d", &u, &v);
~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
7544 KB |
Output is correct |
2 |
Correct |
10 ms |
7416 KB |
Output is correct |
3 |
Correct |
8 ms |
7416 KB |
Output is correct |
4 |
Correct |
8 ms |
7416 KB |
Output is correct |
5 |
Correct |
9 ms |
7544 KB |
Output is correct |
6 |
Correct |
9 ms |
7544 KB |
Output is correct |
7 |
Correct |
9 ms |
7416 KB |
Output is correct |
8 |
Correct |
9 ms |
7416 KB |
Output is correct |
9 |
Correct |
8 ms |
7416 KB |
Output is correct |
10 |
Correct |
9 ms |
7416 KB |
Output is correct |
11 |
Correct |
9 ms |
7544 KB |
Output is correct |
12 |
Correct |
8 ms |
7544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
12564 KB |
Output is correct |
2 |
Correct |
114 ms |
18680 KB |
Output is correct |
3 |
Correct |
64 ms |
12588 KB |
Output is correct |
4 |
Correct |
115 ms |
19836 KB |
Output is correct |
5 |
Correct |
15 ms |
8312 KB |
Output is correct |
6 |
Correct |
98 ms |
15676 KB |
Output is correct |
7 |
Correct |
117 ms |
21240 KB |
Output is correct |
8 |
Correct |
125 ms |
21224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
12392 KB |
Output is correct |
2 |
Correct |
62 ms |
21216 KB |
Output is correct |
3 |
Correct |
62 ms |
21240 KB |
Output is correct |
4 |
Correct |
8 ms |
7416 KB |
Output is correct |
5 |
Correct |
96 ms |
15992 KB |
Output is correct |
6 |
Correct |
103 ms |
13688 KB |
Output is correct |
7 |
Correct |
118 ms |
17212 KB |
Output is correct |
8 |
Correct |
139 ms |
19292 KB |
Output is correct |
9 |
Correct |
126 ms |
18168 KB |
Output is correct |
10 |
Correct |
125 ms |
16888 KB |
Output is correct |
11 |
Correct |
100 ms |
13560 KB |
Output is correct |
12 |
Correct |
121 ms |
15864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
13132 KB |
Output is correct |
2 |
Correct |
90 ms |
21188 KB |
Output is correct |
3 |
Correct |
10 ms |
8312 KB |
Output is correct |
4 |
Correct |
123 ms |
18020 KB |
Output is correct |
5 |
Correct |
133 ms |
18908 KB |
Output is correct |
6 |
Correct |
133 ms |
17628 KB |
Output is correct |
7 |
Correct |
190 ms |
17912 KB |
Output is correct |
8 |
Correct |
190 ms |
19192 KB |
Output is correct |
9 |
Correct |
179 ms |
16908 KB |
Output is correct |
10 |
Correct |
176 ms |
19040 KB |
Output is correct |
11 |
Correct |
183 ms |
16632 KB |
Output is correct |
12 |
Correct |
181 ms |
19060 KB |
Output is correct |
13 |
Correct |
160 ms |
16112 KB |
Output is correct |
14 |
Correct |
167 ms |
20116 KB |
Output is correct |
15 |
Correct |
199 ms |
19192 KB |
Output is correct |
16 |
Correct |
225 ms |
18544 KB |
Output is correct |
17 |
Correct |
175 ms |
16036 KB |
Output is correct |
18 |
Correct |
165 ms |
16096 KB |
Output is correct |