Submission #1113463

# Submission time Handle Problem Language Result Execution time Memory
1113463 2024-11-16T15:47:18 Z Nonoze Make them Meet (EGOI24_makethemmeet) C++17
0 / 100
911 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cmin(a, b) a=min(a, b)
#define cmax(a, b) a=max(a, b)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

void solve();

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	solve();
	return 0;
}

vector<vector<int>> vec;


void print() {
	cout << sz(vec) << endl;
	for (auto &a: vec) {
		for (auto &u: a) cout << u << ' ';
		cout << endl;
	}
	cout << endl;
}

void add(vector<int> &a) { vec.pb(a); }

int n, m;
vector<int> a;
vector<vector<int>> adj;
vector<int> mx;

int dfs(int x, int par=-1) {
	mx[x]=x;
	for (auto u: adj[x]) if (u!=par) {
		cmax(mx[x], dfs(u, x));
	}
	return mx[x];
}

void execute(int x, int base, int par=-1) {
	for (auto u: adj[x]) if (u!=par && mx[u]>base) {
		auto temp=a; temp[x]=0, temp[u]=0;
		add(temp);
		execute(u, base, x);
		add(temp);
	}
}

void solve() {
	cin >> n >> m; a.clear(), a.resize(n, 0); iota(all(a), 1);
	adj.clear(), adj.resize(n), mx.clear(), mx.resize(n);
	mt19937 rng(52);
	vector<int> is(n); iota(all(is), 0); shuffle(all(is), rng);
	for (int i=0; i<m; i++) {
		int u, v; cin >> u >> v;
		u=is[u], v=is[v];
		adj[u].pb(v), adj[v].pb(u);
	}
	for (int i=0; i<n; i++) {
		dfs(i);
		execute(i, i);
	}
	print();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 60 ms 11224 KB If people start at 0 and 1, then they can avoid each other
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Runtime error 911 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB If people start at 0 and 1, then they can avoid each other
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 60 ms 11224 KB If people start at 0 and 1, then they can avoid each other
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 60 ms 11224 KB If people start at 0 and 1, then they can avoid each other
5 Halted 0 ms 0 KB -