답안 #539477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
539477 2022-03-19T03:18:06 Z hhhhaura Semafor (COI20_semafor) C++14
21 / 100
12 ms 476 KB
#define wiwihorz
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()
#define int long long int 
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#ifdef wiwihorz
#define print(a...)cerr<<"Line "<<__LINE__<<":",kout("["+string(#a)+"] = ", a)
void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L)==R], ++L;}
void kout(){cerr<< endl;}
template<class T1,class ... T2>void kout(T1 a,T2 ... e){cerr<<a<<" ",kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define mat vector<vector<int>>
namespace solver {
	int m, n, k, x;
	const int P = 5;
	const int tot = 32;
	mat id, a, b;
	vector<int> v = {
//		1010, 1000, 10010, 11100, 1001, 
//		10101, 110, 11000, 10111, 11101
		10, 8, 18, 28, 9,
		21, 6, 24, 23, 29
	};
	void init_(int _m, int _n, int _k, int _x) {
		m = _m, n = _n, k = _k, x = _x;
		id.assign(tot, vector<int>(tot, 0));
		rep(i, 0, tot - 1) id[i][i] = 1;
		a.assign(tot, vector<int>(tot, 0));
		b.assign(tot, vector<int>(tot, 0));
		rep(i, 0, tot - 1) rep(j, 0, P - 1) {
			a[i ^ (1 << j)][i] = 1;
		}
		b = a;
		rep(i, 0, tot - 1) rep(j, 0, tot - 1) {
			int yes = 0;
			rep(k, 0, 9) if(i == v[k]) yes = 1;
			if(!yes) b[i][j] = 0;
		}
//		rep(t, 1, 3) {
//			mat tmp(tot, vector<int>(tot, 0));
//			rep(i, 0, tot - 1) rep(j, 0, tot - 1) {
//				rep(k, 0, tot - 1) tmp[i][j] += b[i][k] * a[k][j];
//			}
//			b = tmp;
//			print(t);
//			rep(i, 0, tot - 1) {
//				rep(j, 0, tot - 1) {
//					if(b[i][j]) cout << b[i][j] << " ";
//					else cout << ". ";
//				}
//				cout << "\n";
//			}
//		}
	}
	mat mul(mat a, mat b) {
		mat ans(tot, vector<int>(tot, 0));
		rep(i, 0, tot - 1) rep(j, 0, tot - 1) {
			rep(k, 0, tot - 1) ans[i][j] += a[i][k] * b[k][j] % MOD;
			ans[i][j] %= MOD;
		}
		return ans;
	}
	mat pow_(mat a, int times) {
		mat ans = id;
		for(; times > 0; times >>= 1, a = mul(a, a)) {
			if(times & 1) ans = mul(a, ans);
		}
		return ans;
	}
	void solve() {
		mat c = mul(b, pow_(a, k - 1));
		mat d = pow_(c, n / k);
		if(n % k) {
			d = mul(pow_(a, (n - 1) % k), d);
			d = mul(b, d);
		}
		vector<int> ans(tot, 0), sum(10, 0);
		ans[v[x]] = 1;
		rep(i, 0, tot - 1) {
			int val = 0;
			rep(j, 0, tot - 1) val += ans[j] * d[i][j] % MOD;
			rep(j, 0, 9) if(v[j] == i) sum[j] = val;
		}
		rep(i, 0, 9) cout << sum[i] << "\n";
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int m, n, k, x;
	cin >> m >> n >> k >> x;
	init_(m, n, k, x);
	solve();
	return 0;
}


Compilation message

semafor.cpp:17:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   17 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L)==R], ++L;}
      |             ^~~~
semafor.cpp:17:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   17 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L)==R], ++L;}
      |                    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 476 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 320 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 476 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 320 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
12 Correct 7 ms 340 KB Output is correct
13 Correct 8 ms 340 KB Output is correct
14 Correct 12 ms 328 KB Output is correct
15 Correct 11 ms 468 KB Output is correct
16 Correct 11 ms 340 KB Output is correct
17 Correct 12 ms 328 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 11 ms 320 KB Output is correct
21 Correct 8 ms 324 KB Output is correct
22 Correct 8 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -