Skip to content

Instantly share code, notes, and snippets.

@ntopia
ntopia / icpc17-announce.md
Last active October 13, 2017 07:06
2017 ACM-ICPC 대전 리저널 본선 진출팀에게 드리는 안내문

2017 ACM-ICPC 대전 리저널 본선 진출팀에게 드리는 안내문

본선 진출을 축하드립니다! 몇 가지 안내사항이 있습니다. 꼭 읽어주세요.

  1. 휴학 계획이 있는 팀원이 있다면 그 팀은 꼭! 반드시! 저에게 알려주시기 바랍니다.

  2. 팀마다 서약서를 1장씩 작성하셔야 합니다. (서약서 링크) 인쇄해서 자필로 작성하신 뒤, 눕방 프린터 위에 두시면 됩니다. 10월 17일 화요일까지 제출해주시기 바랍니다.

  3. 모든 팀원들은 https://icpc.baylor.edu/ 에 자기 계정으로 로그인한 뒤, 소속팀이 본선 대회로 이동되었는지 확인해주세요. 그 후 "Extra Field의 한글이름" 란에 자신의 이름을 입력하고, 후원사에 대한 개인정보 동의여부(Y 혹은 N)를 입력하셔야 합니다. 이것도 10월 17일 화요일까지 완료해주시기 바랍니다.

@ntopia
ntopia / cf104c.cpp
Created October 8, 2017 10:47
Codeforces Round #104 (Div. 1) C - Lucky Subsequence
#include <cstdio>
#include <unordered_map>
using namespace std;
const int MOD = 1000000007;
int n, k;
int fact[100005], factinv[100005];
unordered_map<int, int> luckyMap;
int luckyCnt[1500];
int unluckyCnt = 0;
@ntopia
ntopia / cf104b.cpp
Created October 8, 2017 10:08
Codeforces Round #104 (Div. 1) B - Lucky Number 2
#include <cstdio>
using namespace std;
int main() {
int a1, a2, a3, a4;
scanf("%d %d %d %d", &a1, &a2, &a3, &a4);
if (a3 == a4 && a1 >= a4 + 1 && a2 >= a4) { // 47474
a1 -= a4 + 1;
a2 -= a4;
for (int i = 0; i < a1; ++i) putchar('4');
@ntopia
ntopia / cf104a.cpp
Created October 8, 2017 08:43
Codeforces Round #104 (Div. 1) A - Lucky Conversion
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char str1[100005], str2[100005];
int main() {
scanf("%s", str1);
scanf("%s", str2);
@ntopia
ntopia / Chimney.cpp
Created May 24, 2017 02:13
SRM 521 Div1 Level3 - Chimney
#include <cstring>
using namespace std;
const int MOD = 1000000007;
void matmul(int mat1[][2], int mat2[][2], int mat3[][2]) {
int tmp[2][2] = {};
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
@ntopia
ntopia / EllysRivers.cpp
Created May 21, 2017 15:41
SRM 543 Div1 Level2 - EllysRivers
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
int step[51];
class EllysRivers {
public:
@ntopia
ntopia / EllysXors.cpp
Created May 21, 2017 10:25
SRM 543 Div1 Level1 - EllysXors
long long f(long long n) {
switch (n % 4) {
case 0: return n;
case 1: return 1;
case 2: return n + 1;
default: return 0;
}
}
class EllysXors {
@ntopia
ntopia / StrangeDictionary2.cpp
Created May 19, 2017 14:21
SRM 542 Div1 Level2 - StrangeDictionary2
#include <vector>
#include <string>
using namespace std;
int failMask[50], matchMask[50];
double dp[1 << 16];
int n, len;
vector<string> words;
double solve(int id) {
@ntopia
ntopia / PatrolRoute.cpp
Created May 18, 2017 11:31
SRM 542 Div1 Level1 - PatrolRoute
class PatrolRoute {
public:
int countRoutes(int X, int Y, int minT, int maxT) {
int ans = 0;
for (int n = 2; n < Y; ++n) {
for (int m = 2; m < X; ++m) {
if ((n + m) * 2 < minT || (n + m) * 2 > maxT) continue;
ans = (ans + 6ll * (n - 1) * (m - 1) * (Y - n) * (X - m)) % 1000000007;
}
}
@ntopia
ntopia / SRMChallengePhase.cpp
Created May 12, 2017 21:28
SRM 520 Div1 Level3 - SRMChallengePhase
#include <vector>
#include <string>
#include <numeric>
using namespace std;
const int MOD = 1000000007;
long long modpow(long long r, long long n) {
long long ret = 1;
for (; n; n /= 2) {