Skip to content

Instantly share code, notes, and snippets.

@hadrori
hadrori / A.txt
Last active November 12, 2016 08:28
G(<= 50,000)人の客とW(<= 50,000)個の洗面所がある.
客にいずれかの洗面所に並ばせて使わせるとき,全員の待ち時間と洗面所を使う時間の総和をWSIという.
最初,それぞれの客の使用時間はわかっている.
そこに1人の客の使用時間を更新させるクエリがQ(<= 10,000)回くるので,更新されるごとにWSIを計算して出力しろ.
テストケース数T(T <= 16)
@hadrori
hadrori / segtree.cpp
Created July 5, 2015 15:21
setgree with range add, range sum
#include <bits/stdc++.h>
using namespace std;
struct segtree {
int N;
vector<int> dat, sum;
segtree(int n) {
N = 1;
while(N < n) N <<= 1;
dat.assign(2*N-1, 0);
@hadrori
hadrori / D.cpp
Last active August 29, 2015 14:19
//////////////////////////////////////////////////////////////////////////////////////////////////
BEGIN_SOLVER ////////////// Coding from here /////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
const string a = "RICHARD", b = "GABRIEL";
int x, h, w;
void solve()
{
#include <bits/stdc++.h>
using namespace std;
int n, m, r, x[100010], y[100010];
map<int,set<int>> es;
inline int dist(int a, int b, int c, int d) { return (a-c)*(a-c)+(d-b)*(d-b);}
int solve()
{
#include <bits/stdc++.h>
using namespace std;
#define double long double
const double eps = 1e-8;
struct point
{
double x, y, z;
point(){}
@hadrori
hadrori / 6848.cpp
Created November 20, 2014 06:31
livearchive 6848
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
inline void chmax(int &a, int b) { a = a<0? b: max(a,b);}
inline void chmin(int &a, int b) { a = a<0? b: min(a,b);}
int r, c, f[128][128], dp[2][128][128][128];
int solve()
{
#include<cstdio>
using namespace std;
int k;
int main() {
scanf("%d",&k);
if(k == 0) printf("3\n1 2 4\n");
if(k == 1) printf("4\n1 3 4 5\n");
if(k == 10) printf("329\n1 2 5 6 17 22 26 27 29 32 34 35 37 40 49 50 53 54 57 58 60 63 66 69 73 74 78 81 82 89 91 95 96 97 99 100 101 107 110 111 119 120 123 126 127 131 135 136 137 138 139 143 144 147 148 151 152 153 155 157 158 159 163 168 169 172 175 183 186 188 192 196 200 205 206 211 213 223 227 228 231 234 236 238 244 246 247 253 256 257 258 259 260 266 268 269 271 276 277 278 287 289 290 291 293 295 297 299 300 302 306 311 313 315 317 325 326 328 339 345 353 357 359 363 367 370 371 379 382 383 384 386 388 390 391 392 393 394 401 404 405 406 407 408 409 411 418 419 420 421 423 427 431 434 438 445 446 449 452 457 460 464 467 468 470 474 475 476 477 481 484 486 487 492 494 496 510 513 516 521 524 528 529 532 537 540 541 544 545 549 550 554 557 559 560 562 567 568 571 573 575 577 578 585 586 590 593 599 610 612 613 615 618 619 630 636 640 642 644 645 646 647 656 657
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int t, n, seq[1<<22];
void left_inc(int &l, deque<pii> &dw, deque<pii> &up)
{
if(!dw.empty() and dw.front().second == l) dw.pop_front();
if(!up.empty() and up.front().second == l) up.pop_front();
#include <bits/stdc++.h>
using namespace std;
int n, m, b[16], p[16], cnt[2], cnt2[2];
set<long long> done;
long long convert(int *v)
{
long long ret = 0;
for (int i = 0; i < n; i++)
@hadrori
hadrori / AOJ2152.cpp
Created October 29, 2013 10:56
solved 2013/10/29
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) repi(i,0,a)
#define pb push_back
#define fst first
#define snd second