답안 #203798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203798 2020-02-22T07:59:05 Z dndhk Amusement Park (CEOI19_amusementpark) C++14
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const int MAX_N = 30;
const ll MOD = 998244353;

int N, M;
vector<int> gp[MAX_N+1];
vector<pii> edge;
int c[MAX_N+1], idx[MAX_N+1];
ll ans;

vector<ll> vt;

set<ll> st;
void chk(){
	for(int i=1; i<=N; i++)	while(!gp[i].empty())	gp[i].pop_back();
	ll now = 0;
	for(int i=0; i<M; i++){
		now<<1LL;
		int u = edge[i].first, v = edge[i].second;
		if(idx[u]<idx[v]){
			int t = u; u = v; v = t;
			now|=1LL;
		}
		gp[u].pb(v);
	}
	vt.pb(now);
}

int per[MAX_N+1];

int main(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<M; i++){
		int x, y; scanf("%d%d", &x, &y); edge.pb({x, y});
	}
	for(int i=0; i<N; i++){
		per[i] = i+1;
	}
	while(1){
		for(int i=0; i<N; i++)	idx[per[i]] = i;
		chk();
		if(!next_permutation(per, per+N))	break;
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	for(int i=0; i<vt.size(); i++){
		for(int j=0; j<M; j++){
			ans = (ans + (vt[i]%2LL)) % MOD;
			vt[i]/=2LL;
		}
	}
	cout<<ans;
	return 0;
}

Compilation message

amusementpark.cpp: In function 'void chk()':
amusementpark.cpp:26:6: warning: statement has no effect [-Wunused-value]
   now<<1LL;
   ~~~^~~~~
amusementpark.cpp: In function 'int main()':
amusementpark.cpp:54:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<vt.size(); i++){
               ~^~~~~~~~~~
amusementpark.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
amusementpark.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x, y; scanf("%d%d", &x, &y); edge.pb({x, y});
             ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -