提出 #28005643
ソースコード 拡げる
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,k,n) for (int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
// using P = pair<ll,ll>;
const ll INF = (ll)1e18;
// const int INF = (int)1e9+7;
template<typename T>
void chmin(T &a, T b) { a = min(a, b); }
template<typename T>
void chmax(T &a, T b) { a = max(a, b); }
using Graph = vector<set<int>>;
void print(vector<int> v) {
rep(i,v.size()) cout << v[i] << ' ';
cout << endl;
}
void solve() {
int n, m;
cin >> n >> m;
Graph takahashi(n), aoki(n);
rep(i,m) {
int a, b;
cin >> a >> b;
a--, b--;
takahashi[a].insert(b);
takahashi[b].insert(a);
}
rep(i,m) {
int a, b;
cin >> a >> b;
a--, b--;
aoki[a].insert(b);
aoki[b].insert(a);
}
vector<int> perm;
rep(i,n) perm.push_back(i);
do {
bool ok = true;
rep(i,n) {
int ai = perm[i]; // 高橋にとっての i が aoki にとっての ai
if (takahashi[i].size() != aoki[ai].size()) {
ok = false;
break;
}
for (int ti : takahashi[i]) {
int aitem = perm[ti];
if (aoki[ai].find(aitem) == aoki[ai].end()) {
ok = false;
break;
}
}
}
if (ok) {
cout << "Yes" << endl;
return;
}
} while (next_permutation(all(perm)));
cout << "No" << endl;
}
int main() {
solve();
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘void print(std::vector<int>)’:
./Main.cpp:4:36: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
4 | #define rep(i,n) for (int i = 0; i < (n); ++i)
| ^
./Main.cpp:21:5: note: in expansion of macro ‘rep’
21 | rep(i,v.size()) cout << v[i] << ' ';
| ^~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
300 / 300 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example_00.txt, example_01.txt, example_02.txt |
| All |
example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| example_00.txt |
AC |
6 ms |
3608 KiB |
| example_01.txt |
AC |
2 ms |
3420 KiB |
| example_02.txt |
AC |
2 ms |
3604 KiB |
| test_00.txt |
AC |
3 ms |
3584 KiB |
| test_01.txt |
AC |
2 ms |
3636 KiB |
| test_02.txt |
AC |
2 ms |
3420 KiB |
| test_03.txt |
AC |
3 ms |
3640 KiB |
| test_04.txt |
AC |
4 ms |
3500 KiB |
| test_05.txt |
AC |
2 ms |
3560 KiB |
| test_06.txt |
AC |
3 ms |
3644 KiB |
| test_07.txt |
AC |
3 ms |
3432 KiB |
| test_08.txt |
AC |
2 ms |
3640 KiB |
| test_09.txt |
AC |
13 ms |
3444 KiB |
| test_10.txt |
AC |
3 ms |
3604 KiB |
| test_11.txt |
AC |
3 ms |
3560 KiB |
| test_12.txt |
AC |
2 ms |
3596 KiB |
| test_13.txt |
AC |
4 ms |
3444 KiB |
| test_14.txt |
AC |
2 ms |
3560 KiB |
| test_15.txt |
AC |
6 ms |
3640 KiB |
| test_16.txt |
AC |
3 ms |
3432 KiB |
| test_17.txt |
AC |
2 ms |
3500 KiB |
| test_18.txt |
AC |
2 ms |
3448 KiB |