Submission #1072229

# Submission time Handle Problem Language Result Execution time Memory
1072229 2024-08-23T15:49:29 Z 7again Mecho (IOI09_mecho) C++14
0 / 100
14 ms 15716 KB
#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

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 time Memory Grader output
1 Runtime error 9 ms 15708 KB Execution killed with signal 11
2 Runtime error 8 ms 15708 KB Execution killed with signal 11
3 Runtime error 8 ms 15704 KB Execution killed with signal 11
4 Runtime error 8 ms 15708 KB Execution killed with signal 11
5 Runtime error 7 ms 15708 KB Execution killed with signal 11
6 Runtime error 9 ms 15708 KB Execution killed with signal 11
7 Runtime error 7 ms 15708 KB Execution killed with signal 11
8 Runtime error 8 ms 15708 KB Execution killed with signal 11
9 Runtime error 8 ms 15504 KB Execution killed with signal 11
10 Runtime error 9 ms 15704 KB Execution killed with signal 11
11 Runtime error 7 ms 15708 KB Execution killed with signal 11
12 Runtime error 7 ms 15708 KB Execution killed with signal 11
13 Runtime error 7 ms 15716 KB Execution killed with signal 11
14 Runtime error 7 ms 15708 KB Execution killed with signal 11
15 Runtime error 9 ms 15708 KB Execution killed with signal 11
16 Runtime error 8 ms 15704 KB Execution killed with signal 11
17 Runtime error 8 ms 15708 KB Execution killed with signal 11
18 Runtime error 7 ms 15708 KB Execution killed with signal 11
19 Runtime error 7 ms 15548 KB Execution killed with signal 11
20 Runtime error 7 ms 15704 KB Execution killed with signal 11
21 Runtime error 7 ms 15476 KB Execution killed with signal 11
22 Runtime error 10 ms 15708 KB Execution killed with signal 11
23 Runtime error 12 ms 15708 KB Execution killed with signal 11
24 Runtime error 8 ms 15708 KB Execution killed with signal 11
25 Runtime error 9 ms 15584 KB Execution killed with signal 11
26 Runtime error 11 ms 15708 KB Execution killed with signal 11
27 Runtime error 9 ms 15708 KB Execution killed with signal 11
28 Runtime error 9 ms 15516 KB Execution killed with signal 11
29 Runtime error 8 ms 15708 KB Execution killed with signal 11
30 Runtime error 9 ms 15708 KB Execution killed with signal 11
31 Runtime error 9 ms 15708 KB Execution killed with signal 11
32 Runtime error 8 ms 15632 KB Execution killed with signal 11
33 Runtime error 8 ms 15536 KB Execution killed with signal 11
34 Runtime error 8 ms 15708 KB Execution killed with signal 11
35 Runtime error 8 ms 15556 KB Execution killed with signal 11
36 Runtime error 7 ms 15704 KB Execution killed with signal 11
37 Runtime error 9 ms 15704 KB Execution killed with signal 11
38 Runtime error 8 ms 15708 KB Execution killed with signal 11
39 Runtime error 9 ms 15708 KB Execution killed with signal 11
40 Runtime error 9 ms 15580 KB Execution killed with signal 11
41 Runtime error 8 ms 15568 KB Execution killed with signal 11
42 Runtime error 8 ms 15708 KB Execution killed with signal 11
43 Runtime error 9 ms 15708 KB Execution killed with signal 11
44 Runtime error 7 ms 15708 KB Execution killed with signal 11
45 Runtime error 8 ms 15708 KB Execution killed with signal 11
46 Runtime error 9 ms 15540 KB Execution killed with signal 11
47 Runtime error 8 ms 15704 KB Execution killed with signal 11
48 Runtime error 8 ms 15704 KB Execution killed with signal 11
49 Runtime error 8 ms 15708 KB Execution killed with signal 11
50 Runtime error 8 ms 15708 KB Execution killed with signal 11
51 Runtime error 8 ms 15708 KB Execution killed with signal 11
52 Runtime error 8 ms 15708 KB Execution killed with signal 11
53 Runtime error 8 ms 15564 KB Execution killed with signal 11
54 Runtime error 8 ms 15708 KB Execution killed with signal 11
55 Runtime error 10 ms 15704 KB Execution killed with signal 11
56 Runtime error 12 ms 15708 KB Execution killed with signal 11
57 Runtime error 8 ms 15708 KB Execution killed with signal 11
58 Runtime error 9 ms 15700 KB Execution killed with signal 11
59 Runtime error 8 ms 15656 KB Execution killed with signal 11
60 Runtime error 8 ms 15708 KB Execution killed with signal 11
61 Runtime error 8 ms 15708 KB Execution killed with signal 11
62 Runtime error 9 ms 15696 KB Execution killed with signal 11
63 Runtime error 8 ms 15712 KB Execution killed with signal 11
64 Runtime error 8 ms 15708 KB Execution killed with signal 11
65 Runtime error 7 ms 15708 KB Execution killed with signal 11
66 Runtime error 9 ms 15708 KB Execution killed with signal 11
67 Runtime error 7 ms 15672 KB Execution killed with signal 11
68 Runtime error 7 ms 15708 KB Execution killed with signal 11
69 Runtime error 9 ms 15708 KB Execution killed with signal 11
70 Runtime error 7 ms 15708 KB Execution killed with signal 11
71 Runtime error 8 ms 15708 KB Execution killed with signal 11
72 Runtime error 10 ms 15708 KB Execution killed with signal 11
73 Runtime error 9 ms 15708 KB Execution killed with signal 11
74 Runtime error 11 ms 15708 KB Execution killed with signal 11
75 Runtime error 13 ms 15708 KB Execution killed with signal 11
76 Runtime error 8 ms 15572 KB Execution killed with signal 11
77 Runtime error 8 ms 15708 KB Execution killed with signal 11
78 Runtime error 8 ms 15636 KB Execution killed with signal 11
79 Runtime error 9 ms 15708 KB Execution killed with signal 11
80 Runtime error 9 ms 15604 KB Execution killed with signal 11
81 Runtime error 9 ms 14684 KB Execution killed with signal 11
82 Runtime error 7 ms 14680 KB Execution killed with signal 11
83 Runtime error 7 ms 14680 KB Execution killed with signal 11
84 Runtime error 14 ms 14736 KB Execution killed with signal 11
85 Runtime error 14 ms 14748 KB Execution killed with signal 11
86 Runtime error 8 ms 14684 KB Execution killed with signal 11
87 Runtime error 8 ms 14684 KB Execution killed with signal 11
88 Runtime error 8 ms 14684 KB Execution killed with signal 11
89 Runtime error 7 ms 14684 KB Execution killed with signal 11
90 Runtime error 7 ms 14684 KB Execution killed with signal 11
91 Runtime error 8 ms 14684 KB Execution killed with signal 11
92 Runtime error 9 ms 14684 KB Execution killed with signal 11