Submission #305405

# Submission time Handle Problem Language Result Execution time Memory
305405 2020-09-23T02:50:06 Z daniel920712 Stations (IOI20_stations) C++14
0 / 100
887 ms 1288 KB
#include "stations.h"
#include <vector>
#include <math.h>
#include <iostream>
#include <stdio.h>
using namespace std;
vector < int > Next[1005];
vector < int > how;
int con[1005]={0};
int ans[1005]={0};
int sz[1005]={0};
bool use[1005]={0};
int st;
void F(int here)
{
    //printf("%d %d\n",here,con);
    int now=0;
    use[here]=1;
    sz[here]=1;
    how.push_back(here);
    for(auto i:Next[here])
    {
        if(!use[i])
        {
            F(i);
            sz[here]+=i;

        }
    }
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
    vector<int> labels;
    how.clear();
    int i;
	for(i=0;i<n;i++)
    {
        labels.push_back(0);
        Next[i].clear();
        con[i]=0;
        use[i]=0;
    }
	for(int i=0;i<n-1;i++)
    {
        con[u[i]]++;
        con[v[i]]++;
        Next[u[i]].push_back(v[i]);
        Next[v[i]].push_back(u[i]);
    }
	F(0);
    for(i=0;i<n;i++) labels[how[i]]=1000*i+(sz[how[i]]-1);
	return labels;
}

int find_next_station(int s, int t, vector<int> c)
{
    int x,n=c.size(),i;
    if(n==1) return c[0];
    if(t/1000>=s/1000+1&&t/1000<=s/1000+s%1000)
    {
        for(i=0;i<n;i++)
        {
            if(c[i]/1000>s/1000)
            {
                if(t/1000>=c[i]/1000&&t/1000<=c[i]/1000+c[i]%1000) return c[i];
            }
        }
    }
    else return c[0];

}

Compilation message

stations.cpp: In function 'void F(int)':
stations.cpp:17:9: warning: unused variable 'now' [-Wunused-variable]
   17 |     int now=0;
      |         ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:57:9: warning: unused variable 'x' [-Wunused-variable]
   57 |     int x,n=c.size(),i;
      |         ^
stations.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
   71 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6008
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1007
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1272 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 Correct 887 ms 868 KB Output is correct
2 Correct 670 ms 868 KB Output is correct
3 Runtime error 3 ms 1288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -