Submission #305416

# Submission time Handle Problem Language Result Execution time Memory
305416 2020-09-23T03:24:20 Z daniel920712 Stations (IOI20_stations) C++14
52.3244 / 100
1022 ms 1124 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]+=sz[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++)
    {
        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]]=i+(sz[how[i]]-1)*1000;
    //for(i=0;i<n;i++) printf("%d ",labels[i]);
    //printf("\n");
	return labels;
}

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

}

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,small=1e9,where;
      |         ^
stations.cpp:79:1: warning: control reaches end of non-void function [-Wreturn-type]
   79 | }
      | ^
stations.cpp:77:24: warning: 'where' may be used uninitialized in this function [-Wmaybe-uninitialized]
   77 |     else return c[where];
      |                        ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=9000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=995000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 597 ms 1024 KB Output is correct
2 Correct 532 ms 1024 KB Output is correct
3 Correct 1001 ms 864 KB Output is correct
4 Correct 675 ms 768 KB Output is correct
5 Correct 597 ms 868 KB Output is correct
6 Correct 457 ms 1024 KB Output is correct
7 Correct 456 ms 768 KB Output is correct
8 Correct 2 ms 868 KB Output is correct
9 Correct 4 ms 876 KB Output is correct
10 Correct 1 ms 884 KB Output is correct
11 Correct 604 ms 896 KB Output is correct
12 Correct 482 ms 1008 KB Output is correct
13 Correct 459 ms 1024 KB Output is correct
14 Correct 455 ms 812 KB Output is correct
15 Correct 54 ms 868 KB Output is correct
16 Correct 65 ms 768 KB Output is correct
17 Correct 102 ms 796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 865 ms 868 KB Output is correct
2 Correct 660 ms 868 KB Output is correct
3 Correct 582 ms 872 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 4 ms 872 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 611 ms 780 KB Output is correct
8 Correct 896 ms 868 KB Output is correct
9 Correct 674 ms 1024 KB Output is correct
10 Correct 586 ms 1008 KB Output is correct
11 Correct 5 ms 880 KB Output is correct
12 Correct 4 ms 868 KB Output is correct
13 Correct 4 ms 768 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 544 ms 768 KB Output is correct
17 Correct 512 ms 876 KB Output is correct
18 Correct 511 ms 1040 KB Output is correct
19 Correct 532 ms 1040 KB Output is correct
20 Correct 484 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 547 ms 1024 KB Partially correct
2 Partially correct 472 ms 768 KB Partially correct
3 Correct 881 ms 864 KB Output is correct
4 Partially correct 658 ms 876 KB Partially correct
5 Partially correct 666 ms 868 KB Partially correct
6 Partially correct 461 ms 1024 KB Partially correct
7 Partially correct 447 ms 780 KB Partially correct
8 Partially correct 3 ms 1008 KB Partially correct
9 Partially correct 4 ms 880 KB Partially correct
10 Partially correct 1 ms 880 KB Partially correct
11 Partially correct 573 ms 796 KB Partially correct
12 Partially correct 566 ms 880 KB Partially correct
13 Correct 1022 ms 868 KB Output is correct
14 Partially correct 792 ms 868 KB Partially correct
15 Partially correct 722 ms 868 KB Partially correct
16 Partially correct 541 ms 1040 KB Partially correct
17 Partially correct 634 ms 768 KB Partially correct
18 Partially correct 535 ms 896 KB Partially correct
19 Partially correct 612 ms 1024 KB Partially correct
20 Partially correct 549 ms 816 KB Partially correct
21 Partially correct 65 ms 868 KB Partially correct
22 Partially correct 89 ms 768 KB Partially correct
23 Partially correct 138 ms 768 KB Partially correct
24 Partially correct 7 ms 768 KB Partially correct
25 Partially correct 7 ms 768 KB Partially correct
26 Partially correct 5 ms 768 KB Partially correct
27 Partially correct 4 ms 872 KB Partially correct
28 Partially correct 1 ms 768 KB Partially correct
29 Partially correct 506 ms 768 KB Partially correct
30 Partially correct 522 ms 872 KB Partially correct
31 Partially correct 551 ms 996 KB Partially correct
32 Partially correct 623 ms 868 KB Partially correct
33 Partially correct 613 ms 768 KB Partially correct
34 Partially correct 388 ms 772 KB Partially correct
35 Partially correct 549 ms 1024 KB Partially correct
36 Partially correct 572 ms 1124 KB Partially correct
37 Partially correct 526 ms 1120 KB Partially correct
38 Partially correct 522 ms 1008 KB Partially correct
39 Partially correct 535 ms 1000 KB Partially correct
40 Partially correct 481 ms 992 KB Partially correct
41 Partially correct 521 ms 1000 KB Partially correct
42 Partially correct 80 ms 940 KB Partially correct
43 Partially correct 104 ms 768 KB Partially correct
44 Partially correct 127 ms 780 KB Partially correct
45 Partially correct 175 ms 1000 KB Partially correct
46 Partially correct 304 ms 812 KB Partially correct
47 Partially correct 319 ms 784 KB Partially correct
48 Partially correct 67 ms 1024 KB Partially correct
49 Partially correct 67 ms 1024 KB Partially correct