Submission #305403

# Submission time Handle Problem Language Result Execution time Memory
305403 2020-09-23T02:48:15 Z daniel920712 Stations (IOI20_stations) C++14
0 / 100
898 ms 1040 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;
    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[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:56:9: warning: unused variable 'x' [-Wunused-variable]
   56 |     int x,n=c.size(),i;
      |         ^
stations.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
   70 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 504 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 Incorrect 6 ms 512 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 4 ms 764 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 898 ms 768 KB Output is correct
2 Incorrect 695 ms 1040 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -