Submission #667683

# Submission time Handle Problem Language Result Execution time Memory
667683 2022-12-01T21:22:08 Z dozer Star Trek (CEOI20_startrek) C++14
8 / 100
1000 ms 3048 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define endl "\n"
#define sp " "
#define pii pair<int, int>
#define st first
#define nd second
#define N 100005
#define int long long

const int modulo = 1e9 + 7;
vector<int> adj[N];
int dp[N][2][2];


int add(int a, int b)
{
	if (a + b < modulo) return a + b;
	return a + b - modulo;
}

int mul(int a, int b)
{
	return (a * b) % modulo;
}


int subs(int a, int b)
{
	if (a < b) return a - b + modulo;
	return a - b;
}

int fe(int a, int b)
{
	if (b == 0) return 1;
	if (b % 2) return mul(a, fe(a, b - 1));
	int tmp = fe(a, b / 2);
	return mul(tmp, tmp);
}

int f(int i, int j, int turn)
{
	int ans = 0;
	if (turn == 0) ans = 1;
	for (auto k : adj[i])
	{
		if (k == j) continue;
		if (turn == 1) ans |= f(k, i, 1 - turn);
		else ans &= f(k, i, 1 - turn);
	}
	return ans;
}

int32_t main()
{
	//fileio();
	fastio();

	int n, d;
	cin>>n>>d;
	for (int i = 1; i <= n; i++)
	{
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
		adj[n + u].pb(n + v);
		adj[n + v].pb(n + u);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			adj[i].pb(n + j);
			if (f(1, 0, 1)) ans++;
			adj[i].pop_back();
		}
	}

	cout<<ans<<endl;
	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Execution timed out 1086 ms 2644 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 43 ms 2676 KB Output is correct
3 Correct 54 ms 2692 KB Output is correct
4 Correct 21 ms 2680 KB Output is correct
5 Correct 23 ms 2644 KB Output is correct
6 Correct 24 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 43 ms 2676 KB Output is correct
3 Correct 54 ms 2692 KB Output is correct
4 Correct 21 ms 2680 KB Output is correct
5 Correct 23 ms 2644 KB Output is correct
6 Correct 24 ms 2680 KB Output is correct
7 Execution timed out 1078 ms 3048 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 43 ms 2676 KB Output is correct
3 Correct 54 ms 2692 KB Output is correct
4 Correct 21 ms 2680 KB Output is correct
5 Correct 23 ms 2644 KB Output is correct
6 Correct 24 ms 2680 KB Output is correct
7 Execution timed out 1078 ms 3048 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 43 ms 2676 KB Output is correct
3 Correct 54 ms 2692 KB Output is correct
4 Correct 21 ms 2680 KB Output is correct
5 Correct 23 ms 2644 KB Output is correct
6 Correct 24 ms 2680 KB Output is correct
7 Execution timed out 1078 ms 3048 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 43 ms 2676 KB Output is correct
3 Correct 54 ms 2692 KB Output is correct
4 Correct 21 ms 2680 KB Output is correct
5 Correct 23 ms 2644 KB Output is correct
6 Correct 24 ms 2680 KB Output is correct
7 Execution timed out 1078 ms 3048 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Execution timed out 1086 ms 2644 KB Time limit exceeded
3 Halted 0 ms 0 KB -