Submission #289899

# Submission time Handle Problem Language Result Execution time Memory
289899 2020-09-03T08:09:25 Z someone_aa Joker (BOI20_joker) C++17
0 / 100
4 ms 6016 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
const int maxn = 200100;
ll n, m, q;

vector<pii>g[maxn];

bool visited[maxn];
int color[maxn];

bool check(int l, int r) {
	memset(visited, false,sizeof(visited));
	memset(color, 0, sizeof(color));

	bool cycle = false;

	for(int i=1;i<=n;i++) {
		if(!visited[i]) {
			visited[i] = true;
			color[i] = 1;

			queue<int>q;
			q.push(i);

			while(!q.empty()) {
				int curr = q.front();
				q.pop();

				for(auto i:g[curr]) {
					if(l <= i.second && i.second <= r) continue;

					if(!visited[i.first]) {
						visited[i.first] = true;
						color[i.first] = 3 - color[curr];
						q.push(i.first);
					}
					else {
						if(color[i.first] == color[curr]) cycle = true;
					}
				}
			}
		}
	}

	return cycle;
}

int main() {
	cin>>n>>m>>q;

	int u, v;
	for(int i=1;i<=m;i++) {
		cin>>u>>v;
		g[u].pb(mp(v, i));
		g[v].pb(mp(u, i));
	}

	int rmost = 0;
	if(!check(1, 1)) rmost = -1;
	else {
		rmost = 1;
		for(ll cekor=m/2;cekor>0;cekor/=2) {
			while(rmost + cekor <= m && check(1, rmost+cekor)) rmost += cekor;
		}
	}

	cout<<rmost<<"\n";

	int l, r;
	while(q--) {
		cin>>l>>r;

		if(r <= rmost) cout<<"YES\n";
		else cout<<"NO\n";
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6016 KB Output isn't correct
2 Halted 0 ms 0 KB -