Submission #1284841

#TimeUsernameProblemLanguageResultExecution timeMemory
1284841Sir_Ahmed_ImranIsland Hopping (JOI24_island)C++17
50 / 100
4 ms532 KiB
#include "island.h" #include <bits/stdc++.h> using namespace std; #define MAXN 301 #define nl '\n' #define ff first #define ss second #define ll long long #define ld long double #define terminator main #define pll pair<ll,ll> #define add insert #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) int c[MAXN]; vector<int> G[MAXN]; bool nei[MAXN][MAXN]; void join(int i, int j){ int k = c[j]; for(auto & v : G[k]){ G[c[i]].append(v); c[v] = c[i]; } G[k].clear(); } void solve(int n, int l){ int j, e; vector<pii> s, t; map<pii, vector<int>> x; for(int i = 1; i <= n; i++){ G[i].append(i); c[i] = i; s.append({0, i}); } e = 0; for(int k = 1; k < n && e < n - 1; k++){ for(auto & [p, i] : s){ j = query(i, k); if(j < p) continue; if(nei[j][i]){ if(c[i] != c[j]){ nei[i][j] = 1; t.append({j, i}); join(i, j); e++; } } else{ nei[i][j] = 1; t.append({j, i}); } } swap(s, t); t.clear(); x.clear(); } for(int i = 1; i < n; i++) for(int j = i + 1; j <= n; j++) if(nei[i][j] && nei[j][i]) answer(i, 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...