Submission #430428

# Submission time Handle Problem Language Result Execution time Memory
430428 2021-06-16T13:41:57 Z alishahali1382 Stations (IOI20_stations) C++14
5 / 100
1216 ms 656 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;
			break ;
		}
	}
	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 Correct 720 ms 528 KB Output is correct
2 Correct 641 ms 528 KB Output is correct
3 Correct 903 ms 400 KB Output is correct
4 Correct 635 ms 404 KB Output is correct
5 Correct 568 ms 400 KB Output is correct
6 Correct 488 ms 540 KB Output is correct
7 Correct 540 ms 512 KB Output is correct
8 Correct 3 ms 464 KB Output is correct
9 Correct 5 ms 480 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 308 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 607 ms 528 KB Output is correct
2 Correct 597 ms 520 KB Output is correct
3 Correct 1216 ms 400 KB Output is correct
4 Correct 949 ms 404 KB Output is correct
5 Correct 868 ms 400 KB Output is correct
6 Correct 660 ms 528 KB Output is correct
7 Correct 524 ms 552 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Incorrect 1 ms 200 KB Invalid labels (duplicates values). scenario=1, label=0
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 929 ms 520 KB Output is correct
2 Correct 739 ms 400 KB Output is correct
3 Correct 640 ms 644 KB Output is correct
4 Correct 3 ms 476 KB Output is correct
5 Correct 6 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Incorrect 1 ms 312 KB Invalid labels (duplicates values). scenario=0, label=0
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 663 ms 520 KB Output is correct
2 Correct 581 ms 656 KB Output is correct
3 Correct 937 ms 400 KB Output is correct
4 Correct 923 ms 400 KB Output is correct
5 Correct 724 ms 400 KB Output is correct
6 Correct 629 ms 520 KB Output is correct
7 Correct 503 ms 528 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Incorrect 4 ms 304 KB Invalid labels (duplicates values). scenario=0, label=0
12 Halted 0 ms 0 KB -