답안 #877620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877620 2023-11-23T11:10:49 Z kh0i Joker (BOI20_joker) C++17
14 / 100
94 ms 15960 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif

using ll = long long;
using pii = pair<int, int>;

#define F first
#define S second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll get_rand(ll l, ll r) {
    assert(l <= r);
    return uniform_int_distribution<ll> (l, r)(rng);
}

const int N = 2e5 + 3;

int n, m, q, L[N], R[N];
vector<pii> g[N];

// contain no odd cycle -> bipartite graph

namespace Sub12{
    bool valid_input(){
        return n <= 2000 and m <= 2000 and q <= 2000;
    }

    int vis[N];

    bool dfs(int u, int l, int r, int col){
        bool ok = 1;
        vis[u] = col;
        for(auto [v, id] : g[u]){
            if(l <= id and id <= r)
                continue;
            if(vis[v])
                ok &= (vis[u] != vis[v]);
            else
                ok &= dfs(v, l, r, col ^ 3);
        }
        return ok;
    }

    void solve(){
        for(int i = 1; i <= q; ++i){
            bool bipartite = 1;
            for(int u = 1; u <= n; ++u)
                vis[u] = 0;
            for(int u = 1; u <= n; ++u){
                if(!vis[u])
                    bipartite &= dfs(u, L[i], R[i], 1);
            }
            cout << (bipartite ? "NO\n" : "YES\n");
        }
    }
}

void solve(){
    cin >> n >> m >> q;
    for(int i = 1; i <= m; ++i){
        int u, v;
        cin >> u >> v;
        g[u].push_back({v, i});
        g[v].push_back({u, i});
    }
    for(int i = 1; i <= q; ++i)
        cin >> L[i] >> R[i];
    if(Sub12::valid_input())
        Sub12::solve();
}

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(0);
    #define task "nohome"
    if(fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int test = 1;
//    cin >> test;
    for(int i = 1; i <= test; ++i){
//        cout << "Case #" << i << ": ";
        solve();
    }
    #ifdef LOCAL
        cerr << "\n[Time]: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
    #endif
    return 0;
}

Compilation message

Joker.cpp: In function 'int32_t main()':
Joker.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6620 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6632 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6636 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6584 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6620 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6632 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6620 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6632 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6636 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6584 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6620 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6632 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 53 ms 6676 KB Output is correct
30 Correct 88 ms 6748 KB Output is correct
31 Correct 84 ms 6760 KB Output is correct
32 Correct 63 ms 6776 KB Output is correct
33 Correct 45 ms 6744 KB Output is correct
34 Correct 91 ms 6748 KB Output is correct
35 Correct 94 ms 6764 KB Output is correct
36 Correct 23 ms 6748 KB Output is correct
37 Correct 53 ms 6748 KB Output is correct
38 Correct 49 ms 6748 KB Output is correct
39 Correct 62 ms 6748 KB Output is correct
40 Correct 53 ms 6744 KB Output is correct
41 Correct 56 ms 6744 KB Output is correct
42 Correct 55 ms 6748 KB Output is correct
43 Correct 44 ms 6748 KB Output is correct
44 Correct 63 ms 6748 KB Output is correct
45 Correct 82 ms 6744 KB Output is correct
46 Correct 89 ms 6756 KB Output is correct
47 Correct 50 ms 6748 KB Output is correct
48 Correct 58 ms 6744 KB Output is correct
49 Correct 71 ms 6768 KB Output is correct
50 Correct 84 ms 6748 KB Output is correct
51 Correct 50 ms 6748 KB Output is correct
52 Correct 63 ms 6748 KB Output is correct
53 Correct 80 ms 6760 KB Output is correct
54 Correct 93 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Incorrect 60 ms 15960 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6620 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6632 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6636 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6584 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6620 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6632 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Incorrect 60 ms 15960 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6620 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6632 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6636 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6584 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6620 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6632 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 53 ms 6676 KB Output is correct
30 Correct 88 ms 6748 KB Output is correct
31 Correct 84 ms 6760 KB Output is correct
32 Correct 63 ms 6776 KB Output is correct
33 Correct 45 ms 6744 KB Output is correct
34 Correct 91 ms 6748 KB Output is correct
35 Correct 94 ms 6764 KB Output is correct
36 Correct 23 ms 6748 KB Output is correct
37 Correct 53 ms 6748 KB Output is correct
38 Correct 49 ms 6748 KB Output is correct
39 Correct 62 ms 6748 KB Output is correct
40 Correct 53 ms 6744 KB Output is correct
41 Correct 56 ms 6744 KB Output is correct
42 Correct 55 ms 6748 KB Output is correct
43 Correct 44 ms 6748 KB Output is correct
44 Correct 63 ms 6748 KB Output is correct
45 Correct 82 ms 6744 KB Output is correct
46 Correct 89 ms 6756 KB Output is correct
47 Correct 50 ms 6748 KB Output is correct
48 Correct 58 ms 6744 KB Output is correct
49 Correct 71 ms 6768 KB Output is correct
50 Correct 84 ms 6748 KB Output is correct
51 Correct 50 ms 6748 KB Output is correct
52 Correct 63 ms 6748 KB Output is correct
53 Correct 80 ms 6760 KB Output is correct
54 Correct 93 ms 6744 KB Output is correct
55 Incorrect 39 ms 13576 KB Output isn't correct
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6620 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 2 ms 6632 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6636 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6584 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6620 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6632 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 53 ms 6676 KB Output is correct
30 Correct 88 ms 6748 KB Output is correct
31 Correct 84 ms 6760 KB Output is correct
32 Correct 63 ms 6776 KB Output is correct
33 Correct 45 ms 6744 KB Output is correct
34 Correct 91 ms 6748 KB Output is correct
35 Correct 94 ms 6764 KB Output is correct
36 Correct 23 ms 6748 KB Output is correct
37 Correct 53 ms 6748 KB Output is correct
38 Correct 49 ms 6748 KB Output is correct
39 Correct 62 ms 6748 KB Output is correct
40 Correct 53 ms 6744 KB Output is correct
41 Correct 56 ms 6744 KB Output is correct
42 Correct 55 ms 6748 KB Output is correct
43 Correct 44 ms 6748 KB Output is correct
44 Correct 63 ms 6748 KB Output is correct
45 Correct 82 ms 6744 KB Output is correct
46 Correct 89 ms 6756 KB Output is correct
47 Correct 50 ms 6748 KB Output is correct
48 Correct 58 ms 6744 KB Output is correct
49 Correct 71 ms 6768 KB Output is correct
50 Correct 84 ms 6748 KB Output is correct
51 Correct 50 ms 6748 KB Output is correct
52 Correct 63 ms 6748 KB Output is correct
53 Correct 80 ms 6760 KB Output is correct
54 Correct 93 ms 6744 KB Output is correct
55 Incorrect 60 ms 15960 KB Output isn't correct
56 Halted 0 ms 0 KB -