0w1

Small tricks

CFR 120 B. Quiz League ( Python read / write file )

Problem - B - Codeforces題意: 很水,不太重要,這裡記錄 python 的讀 / 寫檔。 前三行有,就等價 C++ 開了 freopen() import sys sys.stdin = open( 'input.txt', 'r' ) sys.stdout = open( 'output.txt', 'w' ) N, K = map( int, input().split() ) K -=…

CFR 656 E. Out of Controls ( Python )

Problem - E - Codeforces題意: 給一個 N * N 的鄰接矩陣表示 ( i, j ) 間的邊的距離。問最遠點對的距離為何。 但是,規定不能用類如 for, while, repeat 等關鍵詞 ( 詳見題目本身 )。資料規模: The first line of the input contains a single integer N …

CFR 777 C. Alyona and Spreadsheet ( Python Output Optimization )

Problem - C - Codeforces題意: 給一個 N * M 的矩陣。K 筆詢問,每次問 [ L, R ] 範圍的行是否存在一個列,使得在 [ L, R ] 之間為非遞減。資料規模: The first line of the input contains two positive integers n and m (1 ≤ n·m ≤ 100 000) — the num…

Yuki 164 ちっちゃくないよ!!( std::stoll )

No.164 ちっちゃくないよ!! - yukicoder 進法の変換練習ね。 stoll( const string &str, size_t size, int base = 10 ) leading 0 あっても構わんよ #include <bits/stdc++.h> using namespace std; signed main(){ int N; cin >> N; vector< string > A( N ); for( int i</bits/stdc++.h>…

C++ Tricks - from CFR Blog

http://codeforces.com/blog/entry/15643 There are sure a lot of great techniques many great coders use, especially macros for debugging and so. I find myself not yet familiar with templates and multiple argument or so, but I will not bother…

最近の幾つか小テク

競技プログラミングで陥りやすい言語仕様の罠 - 情報オリンピック 問題と解説 1. これはなんか使えそう。 2. もし intがどこにもあるコードに突然 long longが要求されたら、一番上の行に #define int long long はしたい。しかし、これだと main()が変なも…

Persistent segment tree

2104 -- K-th Number Given n ≤ 1e5 numbers a1, a2 .., an, then there are m ≤ 1e5 queries [ l, r ], for each query, answer the k-th minimum number among al, a(l + 1) .., ar. First we discretize the integers so that there are at most 1e5 inte…

Double and long double

There are many problems that require high precision mathematical operations that we need to implement big number functions. However, sometimes we could avoid this by making use of double and long double, and perhaps some cmath library func…