結果

問題 No.1817 Reversed Edges
ユーザー MasKoaTS
提出日時 2022-01-21 22:33:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,875 bytes
コンパイル時間 4,665 ms
コンパイル使用メモリ 259,916 KB
最終ジャッジ日時 2025-01-27 14:08:54
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <math.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define get(type, n) type n; cin >> n;
#define print(n) cout << (n) << endl
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define ite(i, a) for(auto& i : a)
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
#define lbi(A, x) (ll)(lb(all(A), x) - A.begin())
#define ubi(A, x) (ll)(ub(all(A), x) - A.begin())
using str = string;
using ll = long long;
using Pair = pair<int, int>;
using mint = modint1000000007;
using Mint = modint998244353;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T> >;
const ll INF = 9223372036854775807;
const int inf = 2147483647;
const ll mod = 1000000007;
const ll MOD = 998244353;
template <class T> inline V<T> getList(int n) { V<T> res(n); rep(i, 0, n) { cin >> res[i]; }return res; }
template <class T> inline VV<T> getGrid(int m, int n) { VV<T> res(m, V<T>(n)); rep(i, 0, m) { res[i] = getList<T>(n); }return res; }
template <class T> inline void prints(V<T>& vec) { cout << vec[0]; rep(i, 1, vec.size()) { cout << ' ' << vec[i]; } cout << '\n'; }
inline V<int> dtois(string& s) { V<int> vec = {}; ite(e, s) { vec.push_back(e - '0'); } return vec; }
int count(map<V<int>, int>& mp,VV<int>& route, int a, int b) {
if (mp.find({ a,b }) != mp.end()) {
return mp[{a, b}];
}
mp[{a, b}] = 0;
ite(nv, route[b]) {
if (nv == a) {
continue;
}
mp[{a, b}] += count(mp, route, b, nv);
}
mp[{a, b}] += (a > b);
return mp[{a, b}];
}
int main(void) {
get(int, n);
VV<int> route(n, V<int>(0));
map<V<int>, int> mp = {};
rep(i, 0, n - 1) {
int a, b; cin >> a >> b;
a--; b--;
route[a].push_back(b);
route[b].push_back(a);
}
rep(i, 0, n) {
int ans = 0;
ite(nv, route[i]) {
ans += count(mp, route, i, nv);
}
print(ans);
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0