Submission #305357

# Submission time Handle Problem Language Result Execution time Memory
305357 2020-09-23T01:13:55 Z daniel920712 Stations (IOI20_stations) C++14
0 / 100
1138 ms 1024 KB
#include "stations.h"
#include <vector>
#include <math.h>
#include <iostream>
#include <stdio.h>
using namespace std;
vector < int > Next[1005];
int con[1005]={0};
int ans[1005]={0};
bool use[1005]={0};
int st;
void F(int here,int con,int t)
{
    int now=0;
    ans[here]=con;
    use[here]=1;
    for(auto i:Next[here])
    {
        if(!use[i])
        {
            now++;
            if(st==here) F(i,now,t);
            else F(i,con+t,t);
        }
    }
}

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]);
    }
	for(i=0;i<n;i++)
    {
        if(con[i]>2)
        {
            st=i;
            F(i,0,con[i]);
            break;
        }
    }
    if(i==n)
    {
        st=0;
        F(0,0,con[0]);
    }
    for(i=0;i<n;i++) labels[i]=ans[i];
	return labels;
}

int find_next_station(int s, int t, vector<int> c)
{
    int x;
    if(t==0) return 0;
    if(s==0)
    {
        if(t%c.size()==0) return c.size();
        return t%c.size();
    }
    x=abs(s-c[0]);
    if(s%x==t%x)
    {
        if(s<t) return s+x;
        else return s-x;
    }
    else return s-x;

}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 636 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=5, label=1196
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Invalid labels (duplicates values). scenario=0, label=7
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 546 ms 1024 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1138 ms 1016 KB Output is correct
2 Incorrect 833 ms 876 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 765 ms 1016 KB Wrong query response.
2 Halted 0 ms 0 KB -