Submission #759312

#TimeUsernameProblemLanguageResultExecution timeMemory
759312boyliguanhanJoker (BOI20_joker)C++17
0 / 100
125 ms15964 KiB
#include<bits/stdc++.h> #pragma GCC optimize(2) using namespace std; #define N 200100 vector<int> adj[N]; int color[N], ans[N], a[N], b[N], n, m, q, sz[200]; pair<int, int> arr[200][N]; int dfs(int x, int col) { if(color[x]) { if(col==color[x]) return 0; else return 1; } color[x] = col; for(auto i: adj[x]) if(dfs(i, 3-col)) return 1; return 0; } bool check(int l, int r) { memset(color, 0, sizeof color); for(int i = 1; i <= n; i++) adj[i].clear(); for(int i = 0; i < l; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]); for(int i = r+1; i < m; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]); for(int i = 0; i < n; i++) if(!color[i]) if(dfs(i, 1)) return 1; return 0; } int main() { cin.sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> q; for(int i = 0; i < m; i++) cin >> a[i] >> b[i]; for(int i = 0; i < q; ++i) { int l, r; cin >> l >> r; arr[l-1][sz[l-1]].first = r-1; arr[l-1][sz[l-1]++].second = i; } for(int i = 0; i < m; i++) { sort(arr[i], arr[i] + sz[i]); int l = 0, r = sz[i]-1; while(l<r) { int mid = l+r>>1; if(check(i, arr[i][mid].first)) { l = mid+1; } else { r = mid; } } for(int j = 0; j < l; j++) ans[arr[i][j].second] = 1; for(int j = l; j < sz[i]; ++j) ans[arr[i][j].second] = 0; } for(int i = 0; i < q; i++) cout << (ans[i]?"YES\n":"NO\n"); }

Compilation message (stderr)

Joker.cpp: In function 'int main()':
Joker.cpp:49:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |             int mid = l+r>>1;
      |                       ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...