Submission #234745

#TimeUsernameProblemLanguageResultExecution timeMemory
234745muhammad_hokimiyonCrocodile's Underground City (IOI11_crocodile)C++14
Compilation error
0 ms0 KiB
#include "crocodile.h" #include <bits/stdc++.h> #define fi first #define se second #define ll long long #define dl double long using namespace std; const int NN = 2e6 + 7; const int N = 1e5 + 7; const int M = 22; const int mod = 998244353; const ll inf = 1e18 + 7; const dl rf = 1e-14; const int B = sqrt(N); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int b[N]; bool used[N]; vector < pair < int , ll > > v[N]; pair < ll , int > dfs( int x ) { if( b[x] ){ return {0 , 0}; } used[x] = true; vector < pair < ll , int > > g; for( int i = 0; i < (int)v[x].size(); i++ ){ auto y = v[x][i]; if( used[y.fi] )continue; auto xx = dfs( y.fi ); xx.fi += y.se; //cout << x << " " << y.fi << " " << xx << "\n"; g.push_back(xx); } if( (int)g.size() < 2 )return {g[0].fi , 1}; sort( g.begin() , g.end() ); if( (int)g.size() > 2 && g[1].se == 1 )return g[2].fi; return g[1].fi; } int travel_plan(int n, int m, int a[][2], int l[], int k, int p[]) { for( int i = 0; i < m; i++ ){ a[i][0] += 1 , a[i][1] += 1; } for( int i = 0; i < m; i++ ){ v[a[i][0]].push_back({ a[i][1] , l[i] }); v[a[i][1]].push_back({ a[i][0] , l[i] }); } for( int i = 0; i < k; i++ ){ p[i] += 1; b[p[i]] = 1; } return dfs(1).fi; }

Compilation message (stderr)

crocodile.cpp: In function 'std::pair<long long int, int> dfs(int)':
crocodile.cpp:4:12: error: could not convert 'g.std::vector<std::pair<long long int, int> >::operator[](2).std::pair<long long int, int>::first' from 'long long int' to 'std::pair<long long int, int>'
 #define fi first
crocodile.cpp:41:56: note: in expansion of macro 'fi'
     if( (int)g.size() > 2 && g[1].se == 1 )return g[2].fi;
                                                        ^~
crocodile.cpp:4:12: error: could not convert 'g.std::vector<std::pair<long long int, int> >::operator[](1).std::pair<long long int, int>::first' from 'long long int' to 'std::pair<long long int, int>'
 #define fi first
crocodile.cpp:42:17: note: in expansion of macro 'fi'
     return g[1].fi;
                 ^~