#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
ll res = 1;
x = x; // % mod;
if (x == 0) return 0;
while (y > 0)
{
if (y & 1) res = (res*x) ; // % mod;
y = y>>1;
x = (x*x) ; // % mod;
}
return res;
}
vector<ll> v[N];
ll dp[N];
ll vis[N];
pair<ll,ll> a[N];
bool dfs(ll x, ll par)
{
if(vis[x])
{
if(dp[x]%2==dp[par]%2) return 1;
return 0;
}
dp[x] = dp[par]+1;
vis[x] = 1;
bool ok = 0;
for(int i = 0; i < v[x].sz; i++)
if(v[x][i]!=par) ok|=dfs(v[x][i],x);
return ok;
}
ll n , m , q;
void solve()
{
cin >> n >> m >> q;
for(int i = 1; i <= m; i++)
{
ll x, y; cin >> x >> y;
a[i] = {x,y};
}
while(q--)
{
ll l , r; cin >> l >> r;
for(int i = 1; i < N; i++) v[i].clear();
memset(vis,0,sizeof vis);
for(int i = 1; i <= m; i++)
{
if(i<l||i>r)
{
v[a[i].F].push_back(a[i].S);
v[a[i].S].push_back(a[i].F);
}
}
if(dfs(1,0)) cout << "YES" << endl; else cout << "NO" << endl;
}
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w",stdout);
fast;
// cin >> TT;
while(TT--)
solve();
return 0;
}
Compilation message
Joker.cpp: In function 'bool dfs(ll, ll)':
Joker.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i = 0; i < v[x].sz; i++)
| ^
Joker.cpp:45:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
45 | for(int i = 0; i < v[x].sz; i++)
| ^~~
Joker.cpp:47:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
47 | return ok;
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
Output is correct |
2 |
Correct |
4 ms |
12380 KB |
Output is correct |
3 |
Correct |
4 ms |
12380 KB |
Output is correct |
4 |
Correct |
4 ms |
12608 KB |
Output is correct |
5 |
Correct |
4 ms |
12376 KB |
Output is correct |
6 |
Correct |
10 ms |
12608 KB |
Output is correct |
7 |
Correct |
48 ms |
12380 KB |
Output is correct |
8 |
Incorrect |
53 ms |
12616 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
Output is correct |
2 |
Correct |
4 ms |
12380 KB |
Output is correct |
3 |
Correct |
4 ms |
12380 KB |
Output is correct |
4 |
Correct |
4 ms |
12608 KB |
Output is correct |
5 |
Correct |
4 ms |
12376 KB |
Output is correct |
6 |
Correct |
10 ms |
12608 KB |
Output is correct |
7 |
Correct |
48 ms |
12380 KB |
Output is correct |
8 |
Incorrect |
53 ms |
12616 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
Output is correct |
2 |
Correct |
4 ms |
12380 KB |
Output is correct |
3 |
Execution timed out |
2016 ms |
25728 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
Output is correct |
2 |
Correct |
4 ms |
12380 KB |
Output is correct |
3 |
Correct |
4 ms |
12380 KB |
Output is correct |
4 |
Correct |
4 ms |
12608 KB |
Output is correct |
5 |
Correct |
4 ms |
12376 KB |
Output is correct |
6 |
Correct |
10 ms |
12608 KB |
Output is correct |
7 |
Correct |
48 ms |
12380 KB |
Output is correct |
8 |
Incorrect |
53 ms |
12616 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
Output is correct |
2 |
Correct |
4 ms |
12380 KB |
Output is correct |
3 |
Correct |
4 ms |
12380 KB |
Output is correct |
4 |
Correct |
4 ms |
12608 KB |
Output is correct |
5 |
Correct |
4 ms |
12376 KB |
Output is correct |
6 |
Correct |
10 ms |
12608 KB |
Output is correct |
7 |
Correct |
48 ms |
12380 KB |
Output is correct |
8 |
Incorrect |
53 ms |
12616 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
Output is correct |
2 |
Correct |
4 ms |
12380 KB |
Output is correct |
3 |
Correct |
4 ms |
12380 KB |
Output is correct |
4 |
Correct |
4 ms |
12608 KB |
Output is correct |
5 |
Correct |
4 ms |
12376 KB |
Output is correct |
6 |
Correct |
10 ms |
12608 KB |
Output is correct |
7 |
Correct |
48 ms |
12380 KB |
Output is correct |
8 |
Incorrect |
53 ms |
12616 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |