Created
December 12, 2015 09:39
-
-
Save akouryy/bb94b8ff6aef85b1f3de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
テンプレ略 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int A = next<int>(), B = next<int>(), C = next<int>(), D = next<int>(), X = next<int>(); | |
if(A > B) { | |
int k = X - (A - B) * D; | |
if(k > 0) | |
cout << A + k / (C + D) ln; | |
else | |
cout << B + X / D ln; | |
} else { | |
int k = X - (B - A) * C; | |
if(k > 0) | |
cout << B + k / (C + D) ln; | |
else | |
cout << A + X / C ln; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int N = next<int>(), X = next<int>(), Y = next<int>(), l = 2 * X + Y; | |
string S = next<string>(); | |
int ans = 0; | |
upto(0, N - l, i) { | |
times(X, j) | |
if(S[i + j] != S[i + X - j - 1]) goto pyon; | |
times(Y, j) | |
if(S[i + X + j] != S[i + X + Y - j - 1]) goto pyon; | |
times(X, j) | |
if(S[i + X + Y + j] != S[i + X + Y + X - j - 1]) goto pyon; | |
ans++; | |
pyon:; | |
} | |
cout << ans ln; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
next<int>(); next<int>(); | |
int N = next<int>(); | |
int r = 0, b = 0; | |
times(N, i) { | |
if((next<int>() + next<int>()) % 2) r++; | |
else b++; | |
} | |
cout << b sp << r ln; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int MOD = 100000; | |
int N = next<int>(), M = next<int>(), S = next<int>() - 1, T = next<int>() - 1; | |
vector<int> A(M), B(M), C(M); | |
vector<int> trains[210][100]; | |
times(M, i) { | |
int a = A[i] = next<int>(); | |
int b = B[i] = next<int>() - 1; | |
int c = C[i] = next<int>(); | |
times(110, j) { | |
int k = b + j * c; | |
unless(0 <= k && k < N) break; | |
trains[a + j * abs(c)][k].push_back(i); | |
} | |
} | |
vector<vector<int>> dp(210, vector<int>(N, 0)); | |
dp[0][S] = 1; | |
uptil(1, 210, t) { | |
times(N, j) { | |
dp[t][j] += dp[t - 1][j]; dp[t][j] %= MOD; | |
dout << "dp[" << t << "][" << j << "] = " << dp[t][j] ln; | |
for(int i : trains[t][j]) { | |
int k = j + C[i]; | |
if(0 <= k && k < N) dp[t + abs(C[i])][k] += dp[t][j]; | |
} | |
} | |
} | |
cout << dp[209][T] % MOD; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int N = next<int>(), K2 = next<int>() * 2, C = next<int>(), T = next<int>(); | |
long long Sa = next<int>(), Xa = next<int>(), Ya = next<int>(), Za = next<int>(); | |
long long Sb = next<int>(), Xb = next<int>(), Yb = next<int>(), Zb = next<int>(); | |
long long water = 0; | |
vector<long long> waters(N, 0); | |
times(N, i) { | |
long long A = Sa + 1; | |
long long B = Sb + 1; | |
Sa = (Xa * Sa + Ya) % Za; | |
Sb = (Xb * Sb + Yb) % Zb; | |
long long need = max(0LL, T * B - A + 1); | |
long long p = (need + (C - 1)) / C; | |
if(p > water) water += waters[i] = p - water; | |
if(i >= K2) water -= waters[i - K2]; | |
if(N < 10000) dout << A << "-" << B << "-" << p ln; | |
} | |
if(N < 10000) dout << waters ln; | |
cout << sum(waters) ln; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int MOD = 100000; | |
int N; | |
bool visited[100] = {false}; | |
vector<int> path[100]; | |
int solve(int level, int now) { | |
visited[now] = true; | |
int ans = 0; | |
for(int next : path[now]) { | |
if(next == 0 && level == N - 1) { | |
visited[now] = false; | |
return 1; | |
} | |
unless(visited[next]) | |
ans += solve(level + 1, next); | |
} | |
visited[now] = false; | |
return ans % MOD; | |
} | |
N = next<int>(); int M = next<int>(), D = next<int>(); | |
times(N, i) path[i] = vector<int>(); | |
times(M, i) { | |
int U = next<int>() - 1, V = next<int>() - 1; | |
path[U].push_back(V); | |
path[V].push_back(U); | |
} | |
times(N, i) dout << "(" << path[i].size() << ")" << sorted(path[i]) ln; | |
cout << solve(0, 0) ln; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment