Submission #305365

# Submission time Handle Problem Language Result Execution time Memory
305365 2020-09-23T01:23:31 Z daniel920712 Stations (IOI20_stations) C++14
0 / 100
922 ms 1272 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)
{
    //printf("%d %d\n",here,con);
    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)
{
    //printf("aa\n");
    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 c[0];
    if(s==0)
    {
        if(t%c.size()==0) return c.size();
        return t%c.size();
    }
    if(c.size()==1) return c[0];
    x=abs(s-c[1]);
    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 512 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 562 ms 1272 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 922 ms 768 KB Output is correct
2 Correct 813 ms 768 KB Output is correct
3 Incorrect 667 ms 872 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 599 ms 1024 KB Wrong query response.
2 Halted 0 ms 0 KB -