QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#527126 | #8890. Island Alliances | bachbeo2007 | 0 | 0ms | 0kb | C++23 | 2.3kb | 2024-08-22 10:32:43 | 2024-08-22 10:32:43 |
Judging History
answer
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define ld long double
#define pii pair<int,int>
#define piii pair<pii,int>
#define mpp make_pair
#define fi first
#define se second
const int mod=998244353;
const int maxn=100005;
const int bl=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=20;
const int maxa=1000000;
const int root=3;
const int base=101;
set<int> s[maxn];
int n,par[maxn];
int findpar(int u){
if(u!=par[u]) return par[u]=findpar(par[u]);
return u;
}
bool unions(int u,int v){
u=findpar(u);v=findpar(v);
if(s[u].find(v)!=s[u].end()) return false;
if((int)s[u].size()<(int)s[v].size()) swap(u,v);
par[v]=u;
for(int x:s[v]){
s[u].insert(x);
s[x].erase(v);
s[x].insert(u);
}
return true;
}
void solve(){
int n,m,q;cin >> n >> m >> q;
for(int i=1;i<=n;i++) par[i]=i;
for(int i=1;i<=m;i++){
int u,v;cin >> u >> v;
s[u].insert(v);
s[v].insert(u);
}
for(int i=1;i<=q;i++){
int u,v;cin >> u >> v;
if(unions(u,v)) cout << "APPROVE\n";
else cout << "REFUSE\n";
}
}
signed main(){
freopen("ISLAND.INP","r",stdin);
freopen("ISLAND.OUT","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int test=1;//cin >> test;
while(test--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Dangerous Syscalls
Test #1:
score: 0
Dangerous Syscalls
input:
500 100000 100000 438 332 135 136 263 366 499 464 152 218 108 468 406 253 68 292 172 4 26 164 387 157 100 283 291 331 192 89 81 210 456 200 226 306 67 446 332 161 389 480 106 468 225 292 370 6 396 107 364 10 415 37 162 367 361 495 287 412 373 196 92 70 86 294 279 159 73 111 213 475 154 127 240 136 3...
output:
result:
Subtask #2:
score: 0
Dangerous Syscalls
Test #7:
score: 0
Dangerous Syscalls
input:
100000 250 100000 87753 22052 13044 78494 40286 86692 21189 22558 78512 90619 80348 95509 73181 68207 1058 7977 96443 54748 30078 11315 92868 98488 18943 31255 29398 50255 56004 37701 75918 49644 50803 74243 2396 67674 83011 14838 87869 33260 6215 81554 81950 47045 53217 8222 20380 40891 24740 40716...
output:
result:
Subtask #3:
score: 0
Dangerous Syscalls
Test #13:
score: 0
Dangerous Syscalls
input:
5000 5000 100000 1178 3110 1392 1448 302 3468 3181 4281 3002 1653 1890 1964 88 932 30 1018 1222 4955 2389 2597 3075 1462 3713 2366 1847 837 106 1819 1535 2207 701 272 407 1292 1930 3711 932 776 1635 1316 2004 1519 4407 1133 668 1905 4720 3552 1592 265 3947 4648 1816 1411 4158 1678 2583 2281 4580 272...
output:
result:
Subtask #4:
score: 0
Dangerous Syscalls
Test #19:
score: 0
Dangerous Syscalls
input:
100000 100000 99864 27536 45173 35372 92616 8717 64484 55559 69353 19700 2100 83617 4069 29464 40271 17939 28935 45325 8607 75797 11943 28596 35454 67292 51852 24027 866 6393 45506 19708 28202 42578 41604 9637 96331 50820 4545 27797 18861 35529 93065 36171 34538 25233 77855 2057 97692 80314 4177 260...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%