Submission #1037285

# Submission time Handle Problem Language Result Execution time Memory
1037285 2024-07-28T12:52:06 Z wood Joker (BOI20_joker) C++17
0 / 100
2000 ms 7656 KB
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> p32;
typedef vector<p32> vp32;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second 

int main(){
	int n,m,q; cin>>n>>m>>q;
	vp32 adj[n];
	for(int i = 0; i<m; i++){
		int a,b; cin>>a>>b;
		a--; b--;
		adj[a].eb(b,i+1);
		adj[b].eb(a,i+1);
	}
	for(int j = 0; j<q; j++){
		int l,r; cin>>l>>r;
		int parent[n];
		memset(parent,0,sizeof parent);
		stack<int> qu;
		for(int i = 0; i<n; i++){
			if(!parent[i]){
				qu.push(0);
				while(!qu.empty()){
					int x = qu.top();
					qu.pop();
					for(p32 tt : adj[x]){
						if(tt.se<l||tt.se>r){
							if(parent[tt.fi]&&parent[x]!=tt.fi) goto found;
							if(parent[tt.fi]==0){
								parent[tt.fi] = x;
								qu.push(tt.fi);
							}
						}
					}
				}
			}
		}
		cout<<"NO\n";
		continue;
found:
		cout<<"YES\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2016 ms 7656 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -