본문 바로가기

전체 글91

Codeforces Round #664 (Div. 2) AB #include #include #include #include #include using namespace std; int T; int r, g, b, w; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin >> T; while (T--) { cin >> r >> g >> b >> w; int r_, g_, b_, w_; r_ = r % 2; g_ = g % 2; b_ = b % 2; w_ = w % 2; if (r == 0 || g == 0 || b == 0) { if (r_ + g_ + b_ + w_ == 3 || r_ + g_ + b_ + w_ == 2) cout c; prnt(); visit[r][c] = true; to_tl.. 2020. 8. 13.
KMP from sys import stdin def input(): return stdin.readline().rstrip() def getFail(P): Plen=len(P) ret=[0]*Plen j=0 for i in range(1,Plen): while j>0 and P[i]!=P[j]: j=ret[j-1] if P[i]==P[j]: j+=1 ret[i]=j return ret def KMP(T, P): ret=[] Tlen=len(T) Plen=len(P) j=0 for i in range(Tlen): while j>0 and T[i]!=P[j]: j=fail[j-1] if T[i]==P[j]: if j==Plen-1: ret.append(str(i-Plen+2)) j=fail[j] else: j+=.. 2020. 8. 11.
Codeforces Round #663 (Div. 2) ABC from sys import stdin def input(): return stdin.readline().rstrip() for i in range(int(input())): n=int(input()) for _ in range(1,n+1): print(_,end=" ") print() A - Suborrays 0분에 제출한 사람이 너무 많아서 단순히 n까지 출력하는 도박을 했고 AC를 받았다. from sys import stdin def input(): return stdin.readline().rstrip() T=int(input()) for i in range(T): res=0 r,c=map(int,input().split()) for j in range(r): line=input() if j==.. 2020. 8. 10.
Codeforces Round #662 (Div. 2) ABC from sys import stdin def input(): return stdin.readline().rstrip() for _ in range(int(input())): n=int(input()) print(1+n//2) A - Rainbow Dash, Fluttershy and Chess Coloring 직접 시뮬레이션 해 보면 1 - 2 - 2 - 3 - 3 - 4 - 4 - ... 순으로 답이 됨을 알 수 있다. #include #include #include #include #include using namespace std; int n, q; map plank; char oper; int target; int main() { ios::sync_with_stdio(0); cin.tie(0);.. 2020. 8. 8.
Dijkstra struct Dijkstra { using elem = pair; const ll INF = 2e18; int vol; vector dup; vector adj; Dijkstra(int _vol) { vol = _vol + 1; dup.resize(vol, INF); adj.resize(vol); } void connect(int u, int v, ll w) { adj[u].push_back({w, v}); } void run(int base) { priority_queue que; que.push({0, base}); dup[base] = 0; while (!que.empty()) { auto [cw, id] = que.top(); que.pop(); if (dup[id] < cw) continue; .. 2020. 8. 6.
Tree #include using namespace std; typedef long long ll; const int MAX = 100001; int parent[MAX]; struct Tree { int root, size; vector child[MAX], edge[MAX]; Tree() { root = -1; size = 0; } Tree(int n) { root = -1; size = n; } void addEdge(int u, int v) { edge[u].push_back(v); edge[v].push_back(u); } void build(int id) { if (root == -1) root = id; for (int next : edge[id]) { if (!parent[next]) { pare.. 2020. 8. 6.