제출 #67916

#제출 시각아이디문제언어결과실행 시간메모리
67916boook게임 (IOI14_game)C++14
42 / 100
1091 ms5956 KiB
/*input */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define REP(i,j,k) for(int i = j ; i < k ; ++i) #define RREP(i,j,k) for(int i = j ; i >=k ; --i) #define A first #define B second #define mp make_pair #define pb emplace_back #define PII pair<int , int> #define MEM(i,j) memset(i , j , sizeof i) #define ALL(i) i.begin() , i.end() #define DBGG(i,j) cout << i << " " << j << endl #define DB4(i,j,k,l) cout << i << " " << j << " " << k << " " << l << endl #define IOS cin.tie(0) , cout.sync_with_stdio(0) // #define endl "\n" ///------------------------------------------------------------ #define MAX 1500 #define INF 0x3f3f3f3f struct djs{ int x[MAX] , siz[MAX]; map<int , int> cc[MAX]; void init(){ REP(i , 0 , MAX) x[i] = i , siz[i] = 1; } int Find(int a){ return a == x[a] ? a : x[a] = Find(x[a]); } void Union(int a , int b){ a = Find(a) , b = Find(b); if(a == b) return ; // cc[a].insert(cc[b].begin() , cc[b].end()); for(auto to : cc[b]) cc[a][to.A] += to.B; x[b] = a , siz[a] += siz[b]; } int operator[](int a){ return Find(a); } } ds; int n; void initialize(int _n){ n = _n; ds.init(); } int hasEdge(int a, int b){ a = ds[a]; b = ds[b]; int cnt = 0; ds.cc[a][b] ++; ds.cc[b][a] ++; for(auto to : ds.cc[a]) if(ds[to.A] == b) cnt += to.B; if(cnt == ds.siz[a] * ds.siz[b]) return ds.Union(a , b) , 1; return 0; } // int main(){ // initialize(4); // int a , b; // while(cin >> a >> b){ // cout << hasEdge(a , b) << endl; // } // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...