Skip to content

Instantly share code, notes, and snippets.

View masa-aa's full-sized avatar

まさぁぁ masa-aa

View GitHub Profile
@masa-aa
masa-aa / yuu.cpp
Created August 15, 2021 14:31
ゆうさんろんどん
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <time.h>
#include <vector>
using namespace std;
using vi = vector<int>;
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
INF = n + 1
dp = [INF] * n
c = [0] * n
m = 0
for i, e in enumerate(a):
k = bisect_left(dp, e)
from array import array
def lower_divisors(N):
lower_divisors = array("i")
i = 1
for i in range(1, N + 1):
if i * i > N:
break
if N % i == 0:
from array import array
def lower_divisors(N):
lower_divisors = array("i")
i = 1
for i in range(1, N + 1):
if i * i > N:
break
if N % i == 0:
n = int(input())
s = input()
prev = -1
ans = 0
for i in range(n - 1):
if s[i] != s[i + 1]:
# 前半部分と後半部分を掛け合わせる
ans += (n - i - 1) * (i - prev)
prev = i
# MEMO:Pythonなのでmodの取り方はもっと雑でもいい
def interval_sum(x, y):
# x + (x+1) + ... + (y-1)
x %= mod
y %= mod
return ((y * (y - 1) - x * (x - 1)) // 2) % mod
def solve(x):
# L = 1, R = x についての答え
#include <iostream>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
ll interval_sum(ll x, ll y) {
x %= mod;
y %= mod;
return (y * (y - 1) - x * (x - 1)) / 2 % mod;
}
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
a += a
r = 0 # 右端
c = 0 # sum(a[l:r])
for l in range(n):
while 10 * c < s:
c += a[r]
input();i=-1;print(sum(ord(c)-97<<(i:=i+1)for c in input()))
@masa-aa
masa-aa / 典型068.py
Created June 17, 2021 06:01
典型068
# 偶奇で重みをy - x = v か y - x = -v かで変えて重み付きUnionFindでクエリに答える.
# People on a Line に似ている.
class WeightedUnionFind:
__slots__ = ("root", "diff_weight")
def __init__(self, N):
"""root[v] = vの親, diff_weight[v] = 根からの重み"""
N += 1
self.root = [-1] * N