Skip to content

Instantly share code, notes, and snippets.

@whatalnk
whatalnk / Makefile
Created May 15, 2019 11:30
Makefile for clang++ (AtCoder C++14 / Clang 3.8)
CXX = clang++-3.9
INCDIR = -I /usr/include/c++/v1 -I /home/linuxbrew/.linuxbrew/opt/boost@1.60/include
CFLAGS = -O2
LIBS = -L /usr/lib -L /home/linuxbrew/.linuxbrew/opt/boost@1.60/lib
OBJS = a.out
STD = c++14
STDLIB = libc++
WARNS = -Werror -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic
a.out: hello.cpp
@whatalnk
whatalnk / abc099-c.cpp
Created May 15, 2019 11:28
AtCoder ABC #099 C - Strange Bank
#include <iostream>
using namespace std;
static int n;
int solve();
int solve() {
int ans = n;
for (int i = 0; i <= n; i++) {
@whatalnk
whatalnk / abc099-b.cpp
Created May 15, 2019 10:48
AtCoder ABC #099 B - Stone Monument
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
static int a, b;
int solve();
@whatalnk
whatalnk / abc099-a.cpp
Last active May 15, 2019 07:48
AtCoder ABC #099 A - ABD
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int n;
@whatalnk
whatalnk / agc033-a.cpp
Created May 14, 2019 17:53
AtCoder AGC #033 A - Darker and Darker
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
const int MAX_H = 1000;
const int MAX_W = 1000;
@whatalnk
whatalnk / caddi2018-c.rb
Created May 6, 2019 12:17
CADDi 2018 C - Product and GCD
require 'prime'
n, p_ = gets.chomp.split(" ").map(&:to_i)
x = Prime.prime_division(p_)
ans = 1
x.each do |e, m|
ans *= e ** (m / n)
end
puts ans
@whatalnk
whatalnk / agc033-a.rb
Created May 6, 2019 11:45
AtCoder AGC #033 A - Darker and Darker [Ruby, TLE]
# TLE
H, W = gets.chomp.split(" ").map(&:to_i)
que = []
visited = Array.new(H){Array.new(W, false)}
H.times do |i|
row = gets.chomp
W.times do |j|
if row[j] == "#"
que << [i, j]
@whatalnk
whatalnk / ddcc2019-final-a.rb
Created May 6, 2019 10:34
DDCC 2019 final A - Race
n = gets.chomp.to_i
s = gets.chomp
snow = []
ice = []
cnt = 1
cur = "-"
(n - 1).times do |i|
if s[i + 1] == "-"
if cur == "-"
@whatalnk
whatalnk / dwacon2018-prelims-b.rb
Created May 6, 2019 10:11
Dwacon 2018 prelims B - 2525文字列分解
a = []
b = []
s = gets.chomp
n = s.length
n.times do |i|
if s[i] == "2"
if b.empty?
a << 1
else
x = b.pop
@whatalnk
whatalnk / soundhound2018-summer-final-open-a.rb
Created May 6, 2019 09:53
Soundhound 2018 summer final open A - Feel the Beat
c, d = gets.chomp.split(" ").map(&:to_i)
l, r = 140, 170
ans = 0
while true
break if l > d
ans += [0, [r, d].min - [l, c].max].max
l *= 2
r *= 2
end