# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
416990 | aryan12 | Joker (BOI20_joker) | C++17 | 2074 ms | 20348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
const int N = 200005;
vector<int> g[N];
int color[N];
bool dfs(int node, int col) {
color[node] = col;
for(int i = 0; i < g[node].size(); i++) {
if(color[g[node][i]] == -1) {
if(dfs(g[node][i], 1 - col))
return true;
}
else if(color[g[node][i]] == color[node])
return true;
}
return false;
}
bool isBipartite(int n) {
for(int i = 1; i <= n; i++) {
if(color[i] == -1) {
if(dfs(i, 0))
return true;
}
}
return false;
}
void Solve() {
int n, m, q;
cin >> n >> m >> q;
vector<pair<int, int> > edges;
for(int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
edges.push_back(make_pair(u, v));
}
for(int i = 1; i <= q; i++) {
for(int i = 0; i <= n; i++) {
color[i] = -1;
g[i].clear();
}
int left, right;
cin >> left >> right;
left--, right--;
for(int i = 0; i < left; i++) {
g[edges[i].first].push_back(edges[i].second);
g[edges[i].second].push_back(edges[i].first);
}
for(int i = right + 1; i < m; i++) {
g[edges[i].first].push_back(edges[i].second);
g[edges[i].second].push_back(edges[i].first);
}
if(isBipartite(n)) {
cout << "YES\n";
}
else {
cout << "NO\n";
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
Solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |