Submission #759306

#TimeUsernameProblemLanguageResultExecution timeMemory
759306boyliguanhanJoker (BOI20_joker)C++17
31 / 100
2071 ms22792 KiB
#include<bits/stdc++.h> #pragma GCC optimize(2) using namespace std; #define N 200100 vector<int> adj[N]; vector<pair<int, int>> arr[N]; int color[N], ans[N], a[N], b[N], n, m, q; 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].push_back({r-1,i}); } for(int i = 0; i < 200; i++) { sort(arr[i].begin(), arr[i].end()); int l = 0, r = arr[i].size(); 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 < arr[i].size(); ++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:48:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |             int mid = l+r>>1;
      |                       ~^~
Joker.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int j = l; j < arr[i].size(); ++j)
      |                        ~~^~~~~~~~~~~~~~~
#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...