結果

問題 No.2980 Planar Tree 2
ユーザー 👑 testestest
提出日時 2024-11-25 10:25:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 806 bytes
コンパイル時間 4,368 ms
コンパイル使用メモリ 282,804 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-03 23:30:34
合計ジャッジ時間 9,273 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 RE * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

//愚直
#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using modint=atcoder::modint998244353;

int main(){
	int n;
	cin >> n;
	assert(n<=10);
	vector<pair<int,int>>e;
	vector<int>idx(n);
	iota(idx.begin(),idx.end(),0);

	for(int i=0;i<n-1;i++){
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		e.push_back({x,y});
	}

	int m=n-1;
	int ans=0;
	do{
		int cnt=0;
		for(int i=0;i<m;i++)for(int j=i+1;j<m;j++){
			int a=idx[e[i].first];
			int b=idx[e[i].second]-a;if(b<0)b+=n;
			int c=idx[e[j].first]-a;if(c<0)c+=n;
			int d=idx[e[j].second]-a;if(d<0)d+=n;
			if(0!=c&&0!=d&&b!=c&&b!=d&&(0<c&&c<b)+(0<d&&d<b)==1){
				cnt++;
			}
		}
		if(cnt==0)ans++;
	}while(next_permutation(idx.begin(),idx.end()));

	modint bunbo=1;
	for(int i=1;i<=n;i++)bunbo*=i;
	cout << (ans/bunbo).val() << endl;
}
0