Submission #430426

# Submission time Handle Problem Language Result Execution time Memory
430426 2021-06-16T13:39:56 Z alishahali1382 Stations (IOI20_stations) C++14
0 / 100
1611 ms 568 KB
#include "stations.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())

const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int MAXN=1010;

int n, m, k, x, y, a, b, t, ans;
vi G[MAXN];

vi label(int _n, int _k, vi U, vi V){
	n=_n;
	k=_k;
	vi out(n);
	for (int i=0; i<n; i++) G[i].clear();
	for (int i=0; i<n-1; i++){
		int u=U[i], v=V[i];
		G[u].pb(v);
		G[v].pb(u);
	}
	int v, last;
	for (int i=0; i<n; i++) if (SZ(G[i])==1) v=last=i;
	for (int i=0; i<n; i++){
		out[v]=i;
		for (int u:G[v]) if (u!=last){
			last=v;
			v=u;
		}
	}
	return out;
}

int find_next_station(int s, int t, vi adj){
	if (s<t) return s+1;
	return s-1;
}

Compilation message

stations.cpp: In function 'vi label(int, int, vi, vi)':
stations.cpp:40:20: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |   for (int u:G[v]) if (u!=last){
      |                    ^~
stations.cpp:39:8: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |   out[v]=i;
      |        ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 316 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 328 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 312 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1611 ms 568 KB Output is correct
2 Correct 987 ms 508 KB Output is correct
3 Incorrect 1 ms 316 KB Invalid labels (duplicates values). scenario=0, label=0
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 312 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -