Submission #432223

# Submission time Handle Problem Language Result Execution time Memory
432223 2021-06-18T04:32:47 Z Amylopectin Stations (IOI20_stations) C++14
100 / 100
915 ms 1092 KB
#include <iostream>
#include <vector>
#include "stations.h"
//#include "stub.cpp"
using namespace std;
const int mxn = 2010;
vector <int> pa[mxn] = {};
int clab[mxn] = {},ru = 0;
int re(int cn,int sta,int be)
{
    int i,fn;
    if(sta == 0)
    {
        clab[cn] = ru;
        ru ++;
    }
    for(i=0; i<pa[cn].size(); i++)
    {
        fn = pa[cn][i];
        if(fn == be)
        {
            continue;
        }
        re(fn,(sta+1)%2,cn);
    }
    if(sta == 1)
    {
        clab[cn] = ru;
        ru ++;
    }
    return 0;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
    int i,j,f,t;
	vector<int> lab(n);
	ru = 0;
	for(i=0; i<=n; i++)
	{
        pa[i].clear();
	}
	for(i=0; i<n-1; i++)
	{
        f = u[i];
        t = v[i];
        pa[f].push_back(t);
        pa[t].push_back(f);
	}
	re(0,0,-1);
	for (i = 0; i < n; i++)
	{
		lab[i] = clab[i];
	}
	return lab;
}

int find_next_station(int s, int t, vector<int> c)
{
    int i,j,n = c.size();
    if(s == 0)
    {
        for(i=0; i<n; i++)
        {
            if(t <= c[i])
            {
                return c[i];
            }
        }
        return c[n-1];
    }
    if(s < c[0])
    {
        if(t < s)
            return c[n-1];
        for(i=0; i<n-1; i++)
        {
            if(t <= c[i])
            {
                return c[i];
            }
        }
        return c[n-1];
    }
    if(t > s)
        return c[0];
    for(i=n-1; i>0; i--)
    {
        if(t >= c[i])
        {
            return c[i];
        }
    }
	return c[0];
}
//int main()
//{
//    cout << "Hello world!" << endl;
//    return 0;
//}

Compilation message

stations.cpp: In function 'int re(int, int, int)':
stations.cpp:17:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(i=0; i<pa[cn].size(); i++)
      |              ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:35:11: warning: unused variable 'j' [-Wunused-variable]
   35 |     int i,j,f,t;
      |           ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:59:11: warning: unused variable 'j' [-Wunused-variable]
   59 |     int i,j,n = c.size();
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 534 ms 656 KB Output is correct
2 Correct 476 ms 784 KB Output is correct
3 Correct 915 ms 668 KB Output is correct
4 Correct 711 ms 656 KB Output is correct
5 Correct 618 ms 672 KB Output is correct
6 Correct 496 ms 784 KB Output is correct
7 Correct 444 ms 672 KB Output is correct
8 Correct 3 ms 732 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 513 ms 656 KB Output is correct
2 Correct 570 ms 656 KB Output is correct
3 Correct 882 ms 656 KB Output is correct
4 Correct 643 ms 668 KB Output is correct
5 Correct 625 ms 656 KB Output is correct
6 Correct 447 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 526 ms 924 KB Output is correct
2 Correct 458 ms 800 KB Output is correct
3 Correct 897 ms 656 KB Output is correct
4 Correct 645 ms 656 KB Output is correct
5 Correct 578 ms 664 KB Output is correct
6 Correct 461 ms 924 KB Output is correct
7 Correct 462 ms 784 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 601 ms 836 KB Output is correct
12 Correct 471 ms 904 KB Output is correct
13 Correct 444 ms 804 KB Output is correct
14 Correct 463 ms 656 KB Output is correct
15 Correct 64 ms 656 KB Output is correct
16 Correct 73 ms 656 KB Output is correct
17 Correct 103 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 914 ms 664 KB Output is correct
2 Correct 675 ms 656 KB Output is correct
3 Correct 584 ms 656 KB Output is correct
4 Correct 3 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 2 ms 732 KB Output is correct
7 Correct 627 ms 668 KB Output is correct
8 Correct 880 ms 728 KB Output is correct
9 Correct 593 ms 660 KB Output is correct
10 Correct 541 ms 672 KB Output is correct
11 Correct 6 ms 724 KB Output is correct
12 Correct 6 ms 724 KB Output is correct
13 Correct 8 ms 724 KB Output is correct
14 Correct 5 ms 732 KB Output is correct
15 Correct 2 ms 732 KB Output is correct
16 Correct 546 ms 672 KB Output is correct
17 Correct 544 ms 672 KB Output is correct
18 Correct 545 ms 1092 KB Output is correct
19 Correct 507 ms 660 KB Output is correct
20 Correct 476 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 554 ms 664 KB Output is correct
2 Correct 462 ms 796 KB Output is correct
3 Correct 869 ms 656 KB Output is correct
4 Correct 688 ms 784 KB Output is correct
5 Correct 551 ms 668 KB Output is correct
6 Correct 454 ms 784 KB Output is correct
7 Correct 467 ms 668 KB Output is correct
8 Correct 3 ms 720 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 459 ms 728 KB Output is correct
12 Correct 608 ms 824 KB Output is correct
13 Correct 901 ms 712 KB Output is correct
14 Correct 582 ms 668 KB Output is correct
15 Correct 574 ms 656 KB Output is correct
16 Correct 457 ms 656 KB Output is correct
17 Correct 634 ms 668 KB Output is correct
18 Correct 462 ms 680 KB Output is correct
19 Correct 483 ms 792 KB Output is correct
20 Correct 435 ms 664 KB Output is correct
21 Correct 59 ms 712 KB Output is correct
22 Correct 81 ms 656 KB Output is correct
23 Correct 112 ms 796 KB Output is correct
24 Correct 6 ms 724 KB Output is correct
25 Correct 6 ms 724 KB Output is correct
26 Correct 4 ms 732 KB Output is correct
27 Correct 4 ms 732 KB Output is correct
28 Correct 2 ms 724 KB Output is correct
29 Correct 513 ms 656 KB Output is correct
30 Correct 523 ms 668 KB Output is correct
31 Correct 477 ms 656 KB Output is correct
32 Correct 523 ms 656 KB Output is correct
33 Correct 544 ms 656 KB Output is correct
34 Correct 320 ms 784 KB Output is correct
35 Correct 418 ms 784 KB Output is correct
36 Correct 463 ms 772 KB Output is correct
37 Correct 441 ms 660 KB Output is correct
38 Correct 431 ms 784 KB Output is correct
39 Correct 425 ms 768 KB Output is correct
40 Correct 454 ms 676 KB Output is correct
41 Correct 489 ms 664 KB Output is correct
42 Correct 68 ms 672 KB Output is correct
43 Correct 115 ms 672 KB Output is correct
44 Correct 128 ms 672 KB Output is correct
45 Correct 169 ms 756 KB Output is correct
46 Correct 336 ms 796 KB Output is correct
47 Correct 312 ms 736 KB Output is correct
48 Correct 77 ms 656 KB Output is correct
49 Correct 71 ms 840 KB Output is correct