結果

問題 No.1937 Various Tournament
ユーザー suzushi1isuzushi1i
提出日時 2022-05-13 23:19:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 5,912 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 109,708 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-22 03:36:30
合計ジャッジ時間 5,049 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<functional>
#include<bitset>
#include<math.h>
using namespace std;
void slv(); int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); slv(); return 0; }
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
template<typename T>using vc = vector<T>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vs = vector<string>;
const int INF = 1000000007;
constexpr double PI = 3.14159265358979323846;
constexpr char _ = ' ';
#define endl '\n'
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sz(v) (int)v.size()
#define bg begin()
#define ed end()
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mp make_pair
#define pb emplace_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define tostr to_string
void yesno(bool ans) { cout << (ans ? "yes" : "no") << endl; }
void YesNo(bool ans) { cout << (ans ? "Yes" : "No") << endl; }
void YESNO(bool ans) { cout << (ans ? "YES" : "NO") << endl; }
template<typename T>void i(T& v) { rep(i, sz(v))cin >> v[i]; }
template<typename T, typename U>void i(T& A, U& B) { if (sz(A) - sz(B))return; rep(i, sz(A))cin >> A[i] >> B[i]; }
template<class T, class U, class V>void i(T& A, U& B, V& C) { if (sz(A) - sz(B) || sz(A) - sz(C))return; rep(i, sz(A))cin >> A[i] >> B[i] >> C[i]; }
template<typename T>void o(T& v) { rep(i, sz(v))cout << v[i] << (i != sz(v) - 1 ? _ : '\n'); }
template<typename T>void oendl(T& v) { rep(i, sz(v))cout << v[i] << endl; }
template<typename T, typename U>void oendl(T& A, U& B) { if (sz(A) - sz(B))return; rep(i, sz(A))cout << A[i] << _ << B[i] << endl; }
template<class T, class U, class V>void oendl(T& A, U& B, V& C) { if (sz(A) - sz(B) || sz(A) - sz(C))return; rep(i, sz(A))cout << A[i] << _ << B[i] << _ << C[i] << endl; }
template<typename T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; }return 0; }
template<typename T>bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T>void dedupe(T& v) { v.erase(unique(all(v)), v.end()); }
template<typename T>auto cmprs(T& v) { T vals = v, res(sz(v)); sort(all(vals)), dedupe(vals); rep(i, sz(v))res[i] = lb(all(vals), v[i]) - vals.begin(); return res; }
constexpr int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }, dw[4] = { 1,0,-1,0 }, dh[4] = { 0,1,0,-1 };
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); } ll gcd(ll a, ll b, ll c) { return gcd(gcd(a, b), c); }
template<typename T>bool isprime_Onv(T n) { if (n < 2)return false; for (T i = 2; i * i <= n; i++)if (n % i == 0) { return false; } return true; }
auto Eratosthenes = [](int n) {vector<bool>isprime(n + 1, true); if (n > 0)isprime[0] = false; if (n > 1)isprime[1] = false;
for (int i = 2; i * i <= n; i++) { if (isprime[i])for (int j = i * i; j <= n; j += i) isprime[j] = false; } return isprime; };
template<typename T>vc<T>alldiv(T n) { vc<T>res; for (T i = 1; i * i <= n; i++)if (n % i == 0) { res.pb(i); if (i * i != n)res.pb(n / i); }sort(all(res)); return res; }
ll pow(ll x, ll n) { ll res = 1LL; while (n > 0) { if (n & 1)res *= x; x *= x, n >>= 1; }return res; }
ll pow(ll x, ll n, ll M) { ll res = 1LL; while (n > 0) { if (n & 1)res = res * x % M; x = x * x % M; n >>= 1; }return res; }
bool next_day(int& Y, int& M, int& D) {
	auto m_end = [](int y, int m, int d) {auto L = [](int y) {return y % 4 ? 0 : (y % 100 ? 1 : (y % 400 ? 0 : 1)); };
	return ((d == 31) || (d == 30 && (m == 4 || m == 6 || m == 9 || m == 11)) || !(m - 2 || d - L(y) - 28)) ? 1 : 0; };
	m_end(Y, M, D) ? (M == 12 ? (D = 1, M = 1, Y++) : (D = 1, M++)) : D++; return 1;
}
struct UnionFind {
	UnionFind(int N) { par.resize(N), siz.resize(N); rep(i, N)makeTree(i); }
	bool isSame(int x, int y) { return root(x) == root(y); }
	void unite(int x, int y) { x = root(x), y = root(y); if (x == y)return; siz[x] > siz[y] ? (par[y] = x, siz[x] += siz[y]) : (par[x] = y, siz[y] += siz[x]); }
	int treeSize(int x) { return siz[root(x)]; }
private:
	vector<int>par, siz;
	void makeTree(int x) { par[x] = x, siz[x] = 1; }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
};
template<typename T>struct SegTree {
	SegTree(int _n, function<T(T, T)>_monoid, T _e) :monoid(_monoid), e(_e) { n = 1; while (n < _n)n *= 2; data.assign(2 * n - 1, e); }
	void update(int i, T x) { i += n - 1; data[i] = x; while (i > 0) { i = (i - 1) / 2; data[i] = monoid(data[2 * i + 1], data[2 * i + 2]); } }
	T query(int a, int b) { return query(a, b, 0, 0, n); }
	T operator[](int i) { return data[i]; }
private:
	int n; vector<T>data; function<T(T, T)>monoid; T e;
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) { return e; } if (a <= l && r <= b) { return data[k]; }
		return monoid(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
	}
};




void slv()
{
	int N; cin >> N;
	int t = 0; for (int i = 1; i < N; i *= 2, t++);
	vvi S(N, vi(N));
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++) cin >> S[i][j];
	vl ans(N, 0LL);

	vector<int>A(N); rep(i, N)A[i] = i;

	do
	{
        
        
        
        
		vector<vector<int>>winner(t + 1);
		winner[0] = A;
		for (int i = 0; i < t; i++)
		{
			while (winner[i].size()) {
				int x = winner[i].front(); winner[i].erase(winner[i].begin());
				int y = winner[i].front(); winner[i].erase(winner[i].begin());
				winner[i + 1].push_back(S[x][y] ? x : y);
			}
		}
		ans[winner[t][0]]++;
	} while (next_permutation(all(A)));


	//for (auto& a : ans)a = pow(a, N - 1);
	oendl(ans);
}
0