답안 #914293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914293 2024-01-21T14:34:52 Z Amr Joker (BOI20_joker) C++14
14 / 100
114 ms 856 KB
#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=2e3+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)
{
bool cnt = 1;
    if(vis[x]==cnt)
    {
        if(dp[x]%2==dp[par]%2) return 1;
        return 0;
    }
    dp[x] = dp[par]+1;
    vis[x] = cnt;
    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();
        dp[0] = 0;
        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);
            }
        }
        bool ok = 0;
        for(int i = 1; i <= n; i++)
        {
            if(vis[i]==0)
                ok|=dfs(i,0);
        }
        if(ok) 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:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < v[x].sz; i++)
      |                      ^
Joker.cpp:46:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |     for(int i = 0; i < v[x].sz; i++)
      |     ^~~
Joker.cpp:48:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   48 |         return ok;
      |         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 540 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 540 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 49 ms 604 KB Output is correct
30 Correct 95 ms 856 KB Output is correct
31 Correct 95 ms 664 KB Output is correct
32 Correct 75 ms 644 KB Output is correct
33 Correct 66 ms 632 KB Output is correct
34 Correct 98 ms 652 KB Output is correct
35 Correct 114 ms 656 KB Output is correct
36 Correct 50 ms 604 KB Output is correct
37 Correct 69 ms 668 KB Output is correct
38 Correct 59 ms 636 KB Output is correct
39 Correct 73 ms 604 KB Output is correct
40 Correct 70 ms 604 KB Output is correct
41 Correct 71 ms 604 KB Output is correct
42 Correct 71 ms 676 KB Output is correct
43 Correct 64 ms 644 KB Output is correct
44 Correct 80 ms 644 KB Output is correct
45 Correct 94 ms 604 KB Output is correct
46 Correct 91 ms 604 KB Output is correct
47 Correct 69 ms 632 KB Output is correct
48 Correct 77 ms 600 KB Output is correct
49 Correct 96 ms 636 KB Output is correct
50 Correct 96 ms 648 KB Output is correct
51 Correct 68 ms 600 KB Output is correct
52 Correct 76 ms 664 KB Output is correct
53 Correct 89 ms 672 KB Output is correct
54 Correct 99 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 2 ms 600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 540 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Runtime error 2 ms 600 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 540 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 49 ms 604 KB Output is correct
30 Correct 95 ms 856 KB Output is correct
31 Correct 95 ms 664 KB Output is correct
32 Correct 75 ms 644 KB Output is correct
33 Correct 66 ms 632 KB Output is correct
34 Correct 98 ms 652 KB Output is correct
35 Correct 114 ms 656 KB Output is correct
36 Correct 50 ms 604 KB Output is correct
37 Correct 69 ms 668 KB Output is correct
38 Correct 59 ms 636 KB Output is correct
39 Correct 73 ms 604 KB Output is correct
40 Correct 70 ms 604 KB Output is correct
41 Correct 71 ms 604 KB Output is correct
42 Correct 71 ms 676 KB Output is correct
43 Correct 64 ms 644 KB Output is correct
44 Correct 80 ms 644 KB Output is correct
45 Correct 94 ms 604 KB Output is correct
46 Correct 91 ms 604 KB Output is correct
47 Correct 69 ms 632 KB Output is correct
48 Correct 77 ms 600 KB Output is correct
49 Correct 96 ms 636 KB Output is correct
50 Correct 96 ms 648 KB Output is correct
51 Correct 68 ms 600 KB Output is correct
52 Correct 76 ms 664 KB Output is correct
53 Correct 89 ms 672 KB Output is correct
54 Correct 99 ms 604 KB Output is correct
55 Runtime error 2 ms 600 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 540 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 49 ms 604 KB Output is correct
30 Correct 95 ms 856 KB Output is correct
31 Correct 95 ms 664 KB Output is correct
32 Correct 75 ms 644 KB Output is correct
33 Correct 66 ms 632 KB Output is correct
34 Correct 98 ms 652 KB Output is correct
35 Correct 114 ms 656 KB Output is correct
36 Correct 50 ms 604 KB Output is correct
37 Correct 69 ms 668 KB Output is correct
38 Correct 59 ms 636 KB Output is correct
39 Correct 73 ms 604 KB Output is correct
40 Correct 70 ms 604 KB Output is correct
41 Correct 71 ms 604 KB Output is correct
42 Correct 71 ms 676 KB Output is correct
43 Correct 64 ms 644 KB Output is correct
44 Correct 80 ms 644 KB Output is correct
45 Correct 94 ms 604 KB Output is correct
46 Correct 91 ms 604 KB Output is correct
47 Correct 69 ms 632 KB Output is correct
48 Correct 77 ms 600 KB Output is correct
49 Correct 96 ms 636 KB Output is correct
50 Correct 96 ms 648 KB Output is correct
51 Correct 68 ms 600 KB Output is correct
52 Correct 76 ms 664 KB Output is correct
53 Correct 89 ms 672 KB Output is correct
54 Correct 99 ms 604 KB Output is correct
55 Runtime error 2 ms 600 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -