Submission #612030

#TimeUsernameProblemLanguageResultExecution timeMemory
612030HediChehaidarSimurgh (IOI17_simurgh)C++17
13 / 100
174 ms340 KiB
#include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define dte tuple<double , double , double> using namespace std; const int INF = 1000*1000*1000; // 1 e 9 const int MOD = 1e9 + 7;//998244353 ; const double EPS = 0.000000001; // 1 e -9 const ll inf = (ll)1e18; #include"simurgh.h" /*int count_common_roads(vi v){ cout << "req "; for(auto c : v) cout << c << " "; cout << endl; int ans; cin>>ans; return ans; }*/ int n , m; vi adj[505]; int nb[505][505]; vi v , ans; bool vis[7]; bool ok[50]; int cnt = 0; void dfs(int pos){ if(vis[pos]) return ; vis[pos] = true; cnt++; for(auto c : adj[pos]) if(ok[nb[pos][c]]) dfs(c); } vi find_roads(int N , vi a , vi b){ n = N; m = a.size(); if(n > 7) return ans; for(int i = 0 ; i < m ; i++){ int x = a[i] , y = b[i]; nb[x][y] = nb[y][x] = i; adj[x].pb(y); adj[y].pb(x); } for(int i = 0 ; i < (1 << m) ; i++){ v.clear(); for(int j = 0 ; j < m ; j++){ if((1 << j) & i){ v.pb(j); ok[j] = true; } else ok[j] = false; } if(v.size() != n - 1) continue; memset(vis , 0 , sizeof vis); cnt = 0; dfs(0); if(cnt == n) { int x = count_common_roads(v); if(x == n - 1) return v; } } return ans; } /*int main(){ //ifstream fin ("testing.txt"); //ofstream fout ("output.txt"); ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int nn , mm; cin>>nn>>mm; vi a(mm) , b(mm); for(int i = 0 ; i < mm ; i++) cin>>a[i]>>b[i]; for(auto c : find_roads(nn , a , b)) cout << c << " "; cout << "\n"; return 0; }*/ /* 4 6 0 1 0 2 0 3 1 2 1 3 2 3 */ /* Think of : BS / DFS / BFS / SSSP / SCC / MSP / MAX FLOW / TOPSORT / LCA / MATRIX / DP(bitmask) / 2 POINTERS / SEG TREE / MATH / UN FIND / MO / HLD Read the statement CAREFULLY !! Make a GREADY APPROACH !!!! (start from highest / lowest) Make your own TESTS !! Be careful from CORNER CASES ! */

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:61:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         if(v.size() != n - 1) continue;
      |            ~~~~~~~~~^~~~~~~~
#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...