Submission #311978

# Submission time Handle Problem Language Result Execution time Memory
311978 2020-10-12T05:36:09 Z MonkeyKing Stations (IOI20_stations) C++14
0 / 100
2415 ms 2097156 KB
#include <bits/stdc++.h>
#include "stations.h"
#define all(x) x.begin(),x.end()
using namespace std;
vector <int> edges[1005];
int dfn;

void dfs(int x,int depth,int par,vector <int> &res)
{
    if(depth & 1)
    {
        res[x]=dfn++;
        for(auto u:edges[x])
        {
            if(u==par) continue;
            dfs(u,depth+1,x,res);
        }
    }
    else
    {
        for(auto u:edges[x])
        {
            if(u==par) continue;
            dfs(u,depth+1,x,res);
        }
        res[x]=dfn++;
    }
}

vector <int> label(int n,int k,vector <int> _ea,vector <int> _eb)
{
	dfn=0;
	assert(_ea.size()==n-1);
    vector <int> res;
    res.resize(n);
    for(int i=0;i<n-1;i++)
    {
        edges[_ea[i]].push_back(_eb[i]);
        edges[_eb[i]].push_back(_ea[i]);
    }
    dfs(0,0,-1,res);
    return res;
}

int find_next_station(int s,int t,vector <int> c)
{
    if(s>c[0]) // ºó¸ù
    {
        sort(all(c));
        int par=*c.begin();
        c.erase(c.begin());
        if(c.empty()) return par;
        if(t<c.front() || t>=s) return par;
        reverse(all(c));
        for(auto x:c)
        {
            if(t>=x) return x;
        }
    }
    else // Ïȸù
    {
        sort(all(c));
        int par=*(--c.end());
        c.erase(--c.end());
        if(c.empty()) return par;
        if(t>c.back() || t<=s) return par;
        for(auto x:c)
        {
            if(t<=x) return x;
        }
    }
    // assert(false);
    return -1;
}

Compilation message

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from stations.cpp:1:
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |  assert(_ea.size()==n-1);
      |         ~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1773 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 985 ms 768 KB Output is correct
2 Runtime error 1199 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2415 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -