Submission #393349

# Submission time Handle Problem Language Result Execution time Memory
393349 2021-04-23T09:21:55 Z lighton Stations (IOI20_stations) C++17
0 / 100
1174 ms 640 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
int p = 1;
int chk[1001];
vector<int> vec[1001];
void dfs(int now , int d){
    if((d%2) == 0) chk[now] = p++;
    else chk[now] = 1;
    for(int i : vec[now]){
        if(!chk[i]) dfs(i,d+1);
    }
    if((d%2) == 1) chk[now] = p++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels(n);
    p = 1;
    for(int i = 0; i<n; i++){
        chk[i] = 0;
        vec[i].clear();
    }
    for(int i = 0; i < u.size(); i++){
        vec[v[i]].push_back(u[i]);
        vec[u[i]].push_back(v[i]);
    }
	dfs(0,0);
	for (int i = 0; i < n; i++) {
		labels[i] = chk[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c[c.size()-1] < s){
        if(t > s) return c[0];
        if(t < c[0]) return c[0];
        return *(lower_bound(c.begin() , c.end() , t));
	}
    else{
        if(t < s) return c[c.size()-1];
        if(t > c[c.size()-1]) return c[c.size()-1];
        return *(upper_bound(c.begin() , c.end() , t)-1);
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < u.size(); i++){
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 586 ms 640 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 527 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 563 ms 532 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1174 ms 516 KB Output is correct
2 Incorrect 797 ms 528 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 534 ms 508 KB Wrong query response.
2 Halted 0 ms 0 KB -