Submission #432222

# Submission time Handle Problem Language Result Execution time Memory
432222 2021-06-18T04:15:19 Z Amylopectin Stations (IOI20_stations) C++14
0 / 100
917 ms 904 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])
    {
        for(i=0; i<n-1; i++)
        {
            if(t <= c[i])
            {
                return c[i];
            }
        }
        return c[n-1];
    }
    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 Incorrect 515 ms 904 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 444 ms 660 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 568 ms 776 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 917 ms 656 KB Output is correct
2 Correct 666 ms 672 KB Output is correct
3 Incorrect 615 ms 668 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 536 ms 800 KB Wrong query response.
2 Halted 0 ms 0 KB -