Submission #1072229

#TimeUsernameProblemLanguageResultExecution timeMemory
10722297againMecho (IOI09_mecho)C++14
0 / 100
14 ms15716 KiB
#include <bits/stdc++.h> #define int long long #define endl "\n" #define f first #define s second #define pb push_back #define in insert #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define yes cout<<"Yes\n" #define no cout<<"No\n" #define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0) using namespace std ; void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} const int N = 300000 , MOD = 1e9+7 ; //bool inside(int x,int y){return(x<n&&y<m&&x>-1&&y>-1&&a[x][y]!='#');} //int dx[4]{1 , -1 , 0 , 0} , dy[4]{0 , 0 , 1 , -1} ; vector <pair <int , int>> v[N] ; int n , k , m ; bool ok ; int c[N] , vis[N] ; void dfs(int x) { if(vis[x]) return ; vis[x] = 1 ; for(auto t : v[x]) { if(t.s > m) continue ; if(c[t.f] == c[x]) { ok = 0 ; return ; } c[t.f] = 1 - c[x] ; dfs(t.f) ; } } void slv() { cin >> n >> k ; for(int i = 0 ; i < k ; i++) { int x , y ; cin >> x >> y ; x-- ; y-- ; v[x].pb({y , i}) ; v[y].pb({x , i}) ; } int l = 0 , r = k ; while(l + 1 < r) { m = l + (r - l) / 2 ; ok = 1 ; fill(c , c + n , -1) ; fill(vis , vis + n , 0) ; c[0] = 0 ; dfs(0) ; if(ok) l = m ; else r = m ; } cout << l + 2 ; } main() { //setIO("lasers") ; FAST ; int t = 1 ; //cin >> t ; while(t--) slv() ; }

Compilation message (stderr)

mecho.cpp:83:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   83 | main()
      | ^~~~
mecho.cpp: In function 'void setIO(std::string)':
mecho.cpp:16:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mecho.cpp:16:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...