Submission #951703

# Submission time Handle Problem Language Result Execution time Memory
951703 2024-03-22T11:06:11 Z vjudge1 Amusement Park (CEOI19_amusementpark) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back

int mod = 996244353;

int q[100][100], pos[100], n, m;

bool dfs(int v, int p){
	pos[v] = 1;
	int ok = 0;
	for(int i=1; i<=n; i++){
		if(i == v) continue;
		if(i == p) continue;
		if(!q[v][i]) continue;
		if(pos[i] == 1){
			return 1;
		}
		if(pos[i] == 2){
			continue;
		}
		ok |= dfs(i, v);
		if(ok){
			return 1;
		}
	}
	pos[v] = 2;
	return ok;
}


void solve(){
	cin>>n>>m;
	vector<pii> d;
	for(int i=1; i<=m; i++){
		int l, r;
		cin>>l>>r;
		d.pb({l, r});
		q[l][r] = 1;
	}
	int ans = 0;
	for(int k=0; k<(1 << m); k++){
		for(int i=0; i<n; i++){
			if((k & (1 << i))){
				q[d[i].ff][d[i].ss] = 0;
				q[d[i].ss][d[i].ff] = 1;
			}
			else{
				q[d[i].ff][d[i].ss] = 1;
				q[d[i].ss][d[i].ff] = 0;
			}
			pos[i + 1] = 0;
		}             
		int ok = 0;
		for(int i=1; i<=n; i++){
			if(!pos[i]){
				//ok |= dfs(i, 0);
				if(ok){
					break;
				}
			}
		}  
		if(!ok){
			for(int i=0; i<n; i++){
				if((k & (1 << i))) ans = (ans + 1) % mod;
			}
		}
	}
	cout<<ans;

	
}


int main(){
	solve();
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -