Submission #611984

#TimeUsernameProblemLanguageResultExecution timeMemory
611984HediChehaidarSimurgh (IOI17_simurgh)C++17
0 / 100
3 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]; bool vis[505]; int nb[505][505]; vi v , ans; void dfs(int pos){ if(v.size() == n - 1){ int x = 0; x = count_common_roads(v); if(x == n - 1) ans = v; return; } vis[pos] = true; for(auto c : adj[pos]){ if(!vis[c]){ v.pb(nb[pos][c]); dfs(c); v.pop_back(); } } vis[pos] = false; } vi find_roads(int N , vi a , vi b){ n = N; m = a.size(); 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 < n ; i++) dfs(i); 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 'void dfs(int)':
simurgh.cpp:39:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     if(v.size() == n - 1){
      |        ~~~~~~~~~^~~~~~~~
#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...