Submission #1072022

# Submission time Handle Problem Language Result Execution time Memory
1072022 2024-08-23T13:26:36 Z Abito The Ties That Guide Us (CEOI23_incursion) C++17
0 / 100
211 ms 14788 KB
#include <bits/stdc++.h>
#include "incursion.h"
#define pb push_back
using namespace std;
const int N=5e4+5;
int n,par[N],dp[N],a[N];
vector<int> adj1[N],adj2[N];
bool vis[N];
void dfs1(int x,int p){
	for (auto u:adj1[x]){
		if (u==p) continue;
		dfs1(u,x);
		dp[x]|=dp[u];
	}return;
}
void dfs2(int x,int p){
	par[x]=p;
	for (auto u:adj2[x]){
		if (u==p) continue;
		dfs2(u,x);
	}return;
}
void dfs3(int x,int p){
	if (!a[x]){
		a[par[x]]=visit(par[x]);
		dfs3(par[x],x);
		return;
	}
	for (auto u:adj2[x]){
		if (u==par[x] || u==p) continue;
		a[u]=visit(u);
		if (a[u]==0) visit(x);
		else{
			dfs3(u,x);
			break;
		}
	}
	return;
}
std::vector<int> mark(std::vector<std::pair<int, int>> F, int safe) {
	n=F.size()+1;
	for (auto u:F){
		adj1[u.first].pb(u.second);
		adj1[u.second].pb(u.first);
	}
	dp[safe]=1;
	int r;
	for (int i=1;i<=n;i++) if (adj1[i].size()==2) r=i;
	dfs1(r,0);
	vector<int> v;
	for (int i=1;i<=n;i++) v.pb(dp[i]);
	return v;
}
void locate(std::vector<std::pair<int, int>> F, int curr, int t) {
	n=F.size()+1;
	a[curr]=t;
	for (auto u:F){
		adj2[u.first].pb(u.second);
		adj2[u.second].pb(u.first);
	}
	int r;
	for (int i=1;i<=n;i++) if (adj2[i].size()==2) r=i;
	dfs2(r,0);
	dfs3(curr,0);
	return;
}

Compilation message

incursion.cpp: In function 'void locate(std::vector<std::pair<int, int> >, int, int)':
incursion.cpp:61:6: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |  int r;
      |      ^
incursion.cpp: In function 'std::vector<int> mark(std::vector<std::pair<int, int> >, int)':
incursion.cpp:49:6: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |  dfs1(r,0);
      |  ~~~~^~~~~
interface.cpp: In function 'int main()':
interface.cpp:44:55: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if(fread(T.data(), sizeof(int), 2 * N - 2, stdin) != 2 * N - 2) exit(0);
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
interface.cpp:50:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |         int l = (numbers.size() == N ? N : 0);
      |                  ~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5376 KB Correct
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 14788 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 82 ms 10372 KB Correct
2 Incorrect 78 ms 10644 KB Not correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5376 KB Correct
2 Incorrect 211 ms 14788 KB Not correct
3 Halted 0 ms 0 KB -