Submission #432978

# Submission time Handle Problem Language Result Execution time Memory
432978 2021-06-18T16:42:24 Z MOUF_MAHMALAT Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll in[1009],out[1009],ti;
vector<vector<ll> >v;
void dfs(ll d,ll p)
{
    in[d]=ti;
    for(auto z:v[d])
        if(z!=p)
        {
            ti++;
            dfs(z,d);
        }
    out[d]=ti;
}
vector<int> label(int n, int k, vector<int> U, vector<int> V)
{
    v.resize(n);
    vector<ll>ans(n);
    for(ll i=0; i<U.size(); i++)
    {
        v[U[i]].push_back(V[i]);
        v[V[i]].push_back(U[i]);
    }
    dfs(0,0);
    for(ll i=0; i<n; i++)
        ans[i]=in[i]+(out[i]<<10);
    return ans;
}

int find_next_station(int s, int t, vector<int> c)
{
    ll x=s&(1<<10-1),y=s>>10;
    ll xx=t&(1<<10-1),yy=t>>10;
    for(auto z:c)
    {
        ll o=z&(1<<10-1),oo=z>>10;
        if(x<=xx&&y>=yy&&o<=xx&&oo>=yy)
            return z;
        if((y<xx||x>yy)&&o<=x&&oo>=y)
            return z;
        if(xx<=x&&yy>=y&&o<=x&&oo>=y)
            return z;
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:22:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(ll i=0; i<U.size(); i++)
      |                 ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:35:18: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   35 |     ll x=s&(1<<10-1),y=s>>10;
      |                ~~^~
stations.cpp:36:19: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   36 |     ll xx=t&(1<<10-1),yy=t>>10;
      |                 ~~^~
stations.cpp:39:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   39 |         ll o=z&(1<<10-1),oo=z>>10;
      |                    ~~^~
stations.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3032 ms 1800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2253 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 893 ms 400 KB Output is correct
2 Runtime error 1328 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3031 ms 2097156 KB Time limit exceeded
2 Halted 0 ms 0 KB -