Submission #611982

# Submission time Handle Problem Language Result Execution time Memory
611982 2022-07-29T09:26:00 Z HediChehaidar Simurgh (IOI17_simurgh) C++17
0 / 100
4 ms 340 KB
#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 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);
    }
    dfs(0);
    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;
}
*/
/*
    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

simurgh.cpp: In function 'void dfs(int)':
simurgh.cpp:34:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     if(v.size() == n - 1){
      |        ~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Incorrect 4 ms 340 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB WA in grader: NO
2 Halted 0 ms 0 KB -