Source
stringclasses
1 value
Date
int64
2.01k
2.02k
Text
stringlengths
22
783k
Token_count
int64
20
394k
Project_CodeNet
2,011
#include <iostream> #include <string> #include <map> #include <cassert> using namespace std; map<char,int> match; bool ok = false; pair<int,pair<char,bool> > literal(string &s,int p) { if(s[p] == '~') { return make_pair(p+2,make_pair(s[p+1],false)); } return make_pair(p+1,make_pair(s[p],true));; }...
441
Project_CodeNet
2,011
#include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <cmath> #include <ctime> #include <cassert> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <complex> #include <string> #include <vector> #include <list> #include <deque> #include <stack> #include <...
669
Project_CodeNet
2,011
#include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> #include <math.h> #include <assert.h> #include <vector> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; static const double EPS = 1e-9; static const double PI = acos(-1.0); #define REP...
608
Project_CodeNet
2,011
#include <iostream> #include <cctype> #include <cstdlib> #include <string> #include <memory.h> #include <cmath> #include <vector> #include <algorithm> #include <queue> #include <map> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) typedef long long ll; typedef pair<int, int> P; typedef pair<int,P> PP...
736
Project_CodeNet
2,011
#include <iostream> #include <algorithm> using namespace std; int main() { int L, N, M, X; while (cin >> L >> N >> M >> X && L != 0) { static pair<int,int> sec[100]; for (int i = 0; i < N; i++) { string s; cin >> s >> sec[i].first >> sec[i].second; } static pair<int,int> sta[100]; f...
459
Project_CodeNet
2,011
#include <iostream> using namespace std; bool solve(string s, int start, int end) { char c[3]; bool pos[3]; int count = 0; for (int i = start + 1; i < end; i++) { if (s[i] != '&' && s[i] != '~') { c[count] = s[i]; if (s[i - 1] == '~') pos[count] = false; else pos[count] =...
361
Project_CodeNet
2,011
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <cstring> using namespace std; int main() { while ( true ) // <=20 { int L, N, M, X; cin >>L>>N>>M>>X; if ( L==0 ) break; vector<int> SE(N), SS(N); string tmp; for ( int i=0; i<N; i++ ) cin>>tmp>>SE...
761
Project_CodeNet
2,011
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
1,089
Project_CodeNet
2,011
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);++i) #define SZ(a) ((int)((a).size())) #define REPSZ(i,v) REP(i,SZ(v)) #define ALL(a) (a).begin(),(a).end() template<class T>void pv(T a,T b) {for(T i=...
585
Project_CodeNet
2,011
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
768
Project_CodeNet
2,011
#include<vector> #include<cmath> #include<algorithm> #include<cstdio> #include<iostream> #include<complex> using namespace std; #define REP(i,b,n) for(int i=b;i<n;i++) #define rep(i,n) REP(i,0,n) #define mp make_pair #define fi first #define se second const double pi = acos(-1); typedef complex<double> P; typedef ve...
1,239
Project_CodeNet
2,011
#include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <queue> #include <cstring> #include <deque> #include <cstdio> #include <cmath> #include <complex> #include <iostream> #include <iterator> #include <cctype> using namespace std; #define reep(i,f,t) for(int i=f ; i<int(t) ; ...
365
Project_CodeNet
2,011
#include <iostream> #include <sstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <climits> #include <cfloat> using namespace std; int main() {...
309
Project_CodeNet
2,011
#include<deque> #include<list> #include<map> #include<queue> #include<set> #include<stack> #include<vector> #include<algorithm> #include<string> #include<iostream> #include<sstream> #include<cmath> #include<cstring> using namespace std; int main(){ int i,j; string s; while(cin>>s,s[0]!='#'){ int ln=s.length()...
299
Project_CodeNet
2,011
#include<complex> #include<vector> #include<iostream> #include<stack> #include<cmath> #include<fstream> #include<cstdio> #include<iomanip> #include<algorithm> enum CCW{FRONT=0x01,RIGHT=0x02,BACK=0x04,LEFT=0x08,OVER=0x10}; enum CIRCLE_RELATION{CIRCLE_SAME=0x01,CIRCLE_CONTAIN=0x02, CIRCLE_NO_CROSS=0x04,CIRCLE_ONE...
2,071
Project_CodeNet
2,011
// 2011/09/24 Tazoe #include <iostream> #include <string> #include <map> using namespace std; bool judge(string C) { int V[26]; int v[26]; for(int i=0; i<26; i++) V[i] = v[i] = 0; for(int i=0; i<C.size(); i++){ if(C[i]=='&') continue; int f = 1; if(C[i]=='~'){ f = -1; i++; } if(C[i]>='A'&&...
393
Project_CodeNet
2,011
#include<iostream> #include<sstream> #include<vector> #include<set> #include<map> #include<queue> #include<algorithm> #include<numeric> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #define rep(i,n) for(int i=0;i<n;i++) #define all(c) (c).begin(),(c).end() #define mp make_pair ...
536
Project_CodeNet
2,011
#include <iostream> #include <string> #include <sstream> using namespace std; bool evaluate(istream &is){ int table[256] = { 0 }; is.ignore(); char c = is.get(); while(c != ')'){ if(c == '~'){ c = is.get(); table[c] |= 0x02; // cout << "~" << c << endl; }else{ table[c] |= 0x01; // cout << c << en...
234
Project_CodeNet
2,011
#include <stdio.h> #include <string.h> int main(void){ char s[510]; int flag ; int len; int st; char cp[5]; int pn; char cn[5]; int nn; int i; while( 1 ){ scanf("%s ",s ); if( s[0]=='#' ) break; //printf("%s\n",s ); flag = 1; len = strlen( s ); st=0; while( 1 ){ ...
434
Project_CodeNet
2,019
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static ArrayList<ArrayList<Edge>> g = new ArrayList<>(); public static void main(String[] args) { int N = sc.n...
791
Project_CodeNet
2,019
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util.PriorityQueue; public class Main { static PrintWrite...
1,780
Project_CodeNet
2,019
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <bitset> #include <algorithm> #include <complex> #include <array> using namespace std; #define REP(i,n) for(int i=0; i...
849
Project_CodeNet
2,019
// // Created by yamunaku on 2019/07/14. // #include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (n); i++) #define repl(i, l, r) for(int i = (l); i < (r); i++) #define per(i, n) for(int i = ((n)-1); i >= 0; i--) #define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--) #define all(x) (x...
650
Project_CodeNet
2,019
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { ...
712
Project_CodeNet
2,019
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define REP(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a)...
680
Project_CodeNet
2,019
/* Aa^~ kokoro ga pyonpyon suru n jaa^~ // ZZZXXkXkkkZ!``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ```?Wfpppbpbbpbbpbbbkbkk // ppbbbpbbpVr`` `` ` ` ` ` ```` `` ` ` `` ` ` ` ` ` ` ` ` ` dppbbkkkkkkkkkkqkqkk // HkqqqqqkkWr`` ` ` ``` ``` `?G, ` ` ``.JC!```` ` ` `` `` ````(Wpbkkkkkkkkqkkkkkqk // mmmmmqqqqpr` `` `` ``````...
3,232
Project_CodeNet
2,019
#include <bits/stdc++.h> #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define mkp make_pair typedef long long ll; using namespace std; struct edge { int to, cost; }; int N, M, K, P[100000], C[100000], J[100000], p, q, r; ll res[100000], dist[100000], dist2[100000]...
666
Project_CodeNet
2,019
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #...
599
Project_CodeNet
2,019
#include <cstdio> #include <cstdint> #include <vector> #include <algorithm> #include <queue> #include <utility> #include <tuple> #include <functional> template <typename Weight> struct edge { using value_type = Weight; size_t src, dst; value_type cost; edge(size_t src, size_t dst, value_type cost = 1): sr...
1,032
Project_CodeNet
2,019
#include <iostream> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <tuple> #include <bitset> #include <memory> #include <cmath> #include <algorithm> #include <functional> #include <iomanip> #include <numeric> #include <climits> #include <cfl...
845
Project_CodeNet
2,019
#include <bits/stdc++.h> #pragma GCC Optimize("Ofast") using namespace std; #define int long long #define impl(x, last) x == last ? 0 : 63 - __builtin_clz(x ^ last) struct RadixHeap { int last, size_; vector<tuple<int, int, bool>> bucket_[64]; RadixHeap() : last(0), size_(0){} void emplace(int x, int ...
935
Project_CodeNet
2,019
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<ll, int> P; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = (ll)(1e9+7); #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ a = (a<MOD)?a:(a-MOD); b = (b<MOD)?b:(b-MOD)...
617
Project_CodeNet
2,019
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <iostream> #include <complex> #include <string> #include <algorithm> #include <numeric> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <bitset>...
1,003
Project_CodeNet
2,019
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <string> #include <iomanip> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define int long long int MOD = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, M, K; ci...
712
Project_CodeNet
2,019
/* -*- coding: utf-8 -*- * * 2956.cc: */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #inc...
746
Project_CodeNet
2,019
#include <queue> #include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; const long long inf = 1LL << 60; const long long limit = 1500000000; struct edge { int to; long long cost; }; struct state { int pos, tp; long long cost; }; bool operator<(const state& s1, const st...
679
Project_CodeNet
2,019
#include<bits/stdc++.h> using namespace std; using ll=long long; struct Edge{ int to; ll w; }; const ll INF=1e17; using Graph=vector<vector<Edge>>; class Solver{ int n,m,k; vector<ll> p; vector<ll> c; vector<ll> j; Graph g; vector<ll> res; vector<ll> Dijkstra(vector<ll> d){ ...
535
Project_CodeNet
2,019
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 99999999999999999 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; #define SIZE 100005 struct Edge{ Edge(int arg_to,ll arg_cost){ to = arg_to; cost = arg_cost; }...
725
Project_CodeNet
2,019
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pi; typedef pair<pi, pi> pp; typedef pair<ll, ll> pl; const double EPS = 1e-9; const ll MOD = 1000000007; const int inf = 1 << 30; const ll linf = 1LL <...
867
Project_CodeNet
2,020
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("unroll-loops") //#pragma warning(disable : 4996) #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #define __builtin_popcountll __popcnt64 #endif #include <limits.h> #include <ma...
1,156
Project_CodeNet
2,019
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("tune=native") #pragma GCC target("avx") #pragma GCC target("avx2") // #pragma GCC optimize("unroll-loops") using namespace std; using i64 = int64_t; const i64 MOD = (i64)1e9 + 7; const i64 INF = (i64)1e18 + 7; template <typename T = i64> str...
1,561
Project_CodeNet
2,019
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).begi...
1,284
Project_CodeNet
2,019
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long #define REP(i, n) for (long long i =...
1,485
Project_CodeNet
2,019
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include <random> #include...
862
Project_CodeNet
2,019
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; tem...
579
Project_CodeNet
2,019
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
891
Project_CodeNet
2,019
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> usi...
818
Project_CodeNet
2,019
// #define DEBUGGING #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; using ll = int64_t; using ull = uint64_t; using PLL = pair<ll, ll>; t...
1,053
Project_CodeNet
2,019
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") using namespace std; using ll = long long; using P = pair<ll, ll>; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll LINF = (1LL << 60) - 1LL; constexpr do...
989
Project_CodeNet
2,019
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; struct Edge { int to, cost; }; template<class T, class Edge> V<T> dijkstra(const VV<Edge>& g, int s = 0) { V<T> dist(g.size(), numeric_limits<T>::max()); ...
548
Project_CodeNet
2,019
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; tem...
579
Project_CodeNet
2,019
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> mp; ll inf = 1e12; int main(){ ll n,m,k; cin>>n>>m>>k; vector<ll> p(n),c(n),j(n); vector<vector<mp> > g(n); for(int i=0;i<n;i++)cin>>p[i]; for(int i=0;i<n;i++)cin>>c[i]; for(int i=0;i<n;i++)cin>>j[i...
620
Project_CodeNet
2,019
// need #include <iostream> #include <algorithm> // data structure #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <complex> //#include <deque> #include <valarray> #include <unordered_map> #include <unordered_set> #include...
2,006
Project_CodeNet
2,019
#include <bits/stdc++.h> using namespace std; typedef pair<int64_t, int64_t> P; const int64_t INF = 1e18; void dijkstra(int N, vector<P> edges[], vector<int64_t>& dist){ priority_queue<P, vector<P>, greater<P>> que; for(int i=0; i<N; i++) que.push({dist[i], i}); while(que.size()){ auto p = que.top...
504
Project_CodeNet
2,019
use std::cmp; use std::collections::BinaryHeap; const INF: i64 = std::i64::MAX; fn main() { let s = std::io::stdin(); let mut sc = Scanner { stdin: s.lock() }; let n: usize = sc.read(); let m: usize = sc.read(); let k: usize = sc.read(); let bread: Vec<i64> = sc.vec(n); let jam_kind: Vec<...
935
Project_CodeNet
2,019
use std::cmp; use std::collections::BinaryHeap; const INF: i64 = std::i64::MAX; fn main() { let s = std::io::stdin(); let mut sc = Scanner { stdin: s.lock() }; let n: usize = sc.read(); let m: usize = sc.read(); let k: usize = sc.read(); let bread: Vec<i64> = sc.vec(n); let jam_kind: Vec<...
935
Project_CodeNet
2,019
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufRea...
1,341
Project_CodeNet
2,019
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> typedef int32_t i32; typedef int64_t i64; typedef struct binary_heap { void *array; size_t heap_size; size_t max_size; size_t val_size; int (*cmp) (const void *, const void *); } heap; heap* new_binary_heap (const size_t val_size,...
2,152
Project_CodeNet
2,019
import sys from heapq import heappop as hpp, heappush as hp def dijkstra(N, s, Edge): inf = 10**18 dist = [inf] * N Q = [(0, s)] decided = set() for _ in range(N): while True: dn, vn = hpp(Q) if vn not in decided: decided.add(vn) dist[v...
458
Project_CodeNet
2,019
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.IO; using System.Text; using System.Diagnostics; using static util; using P = pair<int, int>; using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Ex...
4,086
Project_CodeNet
2,020
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); DoubleList[] lists = new DoubleList[n]; for (int i = 0; i < n; i++) { lists[i] = new DoubleList(i); ...
537
Project_CodeNet
2,018
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; } template<c...
1,579
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; int n,q; int a[100005]; int f[100005],t[100005]; int s,g; int main(void){ scanf("%d%d",&n,&q); for(int i=0;i<n;i++){ scanf("%d",&a[i]); } s=a[0]; g=a[n-1]; for(int i=0;i+1<n;i++){ t[a[i]]=a[i+1]; } for(int i=0;i+1<n;i++){ f[a[i+1]]=a[i]; //printf("%d %d\...
391
Project_CodeNet
2,018
#include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<array> #include<map> #include<iomanip> #include<assert.h> #inc...
863
Project_CodeNet
2,018
#include <bits/stdc++.h> #define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME #define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl #define pr1(a) (#a)<<"="<<(a)<<" " #define pr2(a,b) pr1(a)<<pr1(b) #define pr3(a,b,c) pr1(a)<<pr2(b,c) #define pr4(a,b,c,d) pr1(a)<<pr3(b,c,...
1,153
Project_CodeNet
2,018
#include<bits/stdc++.h> using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ Int n,q; cin>>n>>q; vector<Int> A(n),B(q); for(Int i=0;i<n;i++) cin>>A[i]; for(Int i=0;i<q;i++) cin>>B[i]; if(n==1){ cout<<1<<endl; return 0; } vector<Int> L(n+1,0),R(n+1,0); for(Int i=0;...
408
Project_CodeNet
2,018
#include <bits/stdc++.h> #define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME #define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl #define pr1(a) (#a)<<"="<<(a)<<" " #define pr2(a,b) pr1(a)<<pr1(b) #define pr3(a,b,c) pr1(a)<<pr2(b,c) #define pr4(a,b,c,d) pr1(a)<<pr3(b,c,...
1,153
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; using int64 = long long; int main() { int N, Q; cin >> N >> Q; vector< int > A(N); const int SQ = 333; for(int i = 0; i < N; i++) { cin >> A[i]; --A[i]; } vector< int > pending; for(int i = 0; i < Q; i++) { int q; cin >> q; --q; p...
540
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << end...
827
Project_CodeNet
2,019
#include <cstdio> #include <cstdint> #include <cstddef> #include <algorithm> #include <utility> #include <memory> #include <array> constexpr intmax_t operator ""_jd(unsigned long long n) { return n; } constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; } constexpr size_t operator ""_zu(unsigned lo...
6,570
Project_CodeNet
2,019
#include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; const double PI = 3.1415926535897932384626433832795; const ll MOD = 1000000007; const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { -1, 0, 1, 0 }; int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); } ll gcd(ll x, l...
730
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define pb push_back #define l first #define r second using pi = pair<int,int>; int main(){ int n,Q; cin >>n >>Q; vector<int> x(n); rep(i,n) cin >>x[i]; int H = n+1, T = n+2; vector<pi> a(n+3);...
571
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int N, Q; cin >> N >> Q; int prev[N+1] = {}; int next[N+1] = {}; int head, tail; int A[N]; for ( int i = 0; i < N; i++ ) { cin >> A[i]; if ( i ) { prev[A[i]] = A[i-1]; next[A[i-1]] = A[i]; ...
436
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++) int n,q; int a[125252]; int bef[125252], aft[125252]; int main(){ scanf("%d%d",&n,&q); REP(i,n)scanf("%d",a+i),a[i]--; if(n==1){ printf("%d\n",a[0]+1); retu...
564
Project_CodeNet
2,018
#include<bits/stdc++.h> using namespace std; typedef long long LL; #define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define REC(ret, ...) std::function<ret (__VA_ARGS__)> template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; retur...
546
Project_CodeNet
2,018
#include <iostream> #include <string> using namespace std; int nex[100005],pre[100005]; int a[100005]; int head = 0,tail; int n, q, tmp1, tmp2; void print(){ int p=nex[head]; int a=0; while( p != tail){ if(a)cout<<' '; a++; cout<<p; p=nex[p]; } cout<<endl; } int main(void){ cin >> n >> q; if(n == 1)...
666
Project_CodeNet
2,019
#include<bits/stdc++.h> using namespace std; //type typedef long long ll; #define pii pair<int, int> #define vi vector<int> //x * y * 1.0 can cause overflow //constant #define inf (int)(1e9+7) #define mod (ll)(1e9+7) #define eps 1e-10 //omission #define eb emplace_back #define F first #define S second #define SZ(x) ((i...
1,154
Project_CodeNet
2,018
#define NDEBUG #include <cstddef> #include <cstdint> #include <vector> using i8 = ::std::int_least8_t; using i32 = ::std::int_least32_t; using i64 = ::std::int_least64_t; using u8 = ::std::uint_least8_t; using u32 = ::std::uint_least32_t; using u64 = ::std::uint_least64_t; using isize = ::std::ptrdiff_t; using usize =...
774
Project_CodeNet
2,018
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long lo...
795
Project_CodeNet
2,018
#include<bits/stdc++.h> #include<random> using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; #define MOD 1000000007LL #define INF 1000000000ll #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size(...
486
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<int(n);i++) #define rep1(i,n) for(int i=1;i<=int(n);i++) #define debug(x) cerr<<#x<<": "<<x<<endl int main(){ int n,Q; cin>>n>>Q; vector<int> a(n+2), pre(n+2), nxt(n+2), q(Q); rep1(i,n){ cin>>a[i]; } rep(i,Q) ...
426
Project_CodeNet
2,018
#include<iomanip> #include<limits> #include<thread> #include<utility> #include<iostream> #include<string> #include<algorithm> #include<set> #include<map> #include<vector> #include<stack> #include<queue> #include<cmath> #include<numeric> #include<cassert> #include<random> #include<chrono> #include<unordered_map> #includ...
731
Project_CodeNet
2,018
#include <iostream> #include <vector> using namespace std; struct node { int val; node *left, *right; node() : val(-1), left(NULL), right(NULL) { } }; void print(node* cur) { while (cur != NULL) { cout << cur->val + 1; if (cur->right) cout << " "; cur = cur->right; } co...
512
Project_CodeNet
2,018
#include <bits/stdc++.h> using namespace std; int n, q, head, last; int pre[100005] = {0}; int suf[100005] = {0}; void solve(int x); int main() { int bf; cin >> n >> q; if(n == 1) { cout << 1 << endl; return 0; } for(int i = 0; i < n; ++i) { int x; cin >> x; if(i == 0) { head = x;...
450
Project_CodeNet
2,018
#include <stdio.h> int a[100001]; int pos[100000]; void swap(int *x, int *y) { int tmp = *x; *x = *y; *y = tmp; } int main() { int n, q; scanf("%d %d", &n, &q); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); a[i]--; pos[a[i]] = i; } int k = n; while (q--) { int b; scanf("%d",...
223
Project_CodeNet
2,018
#include <iostream> #include <vector> using namespace std; const int N = 100010; int next[N]; int prev[N]; void update(int n, int qi){ int a1 = next[0]; int aj_m1 = prev[qi]; int aj_p1 = next[qi]; int an = prev[n+1]; if (n == 1){ return; } if (a1 == qi){ next[0] = aj_p1; next[qi] = n+1; ...
513
Project_CodeNet
2,018
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i...
479
Project_CodeNet
2,020
#include <algorithm> #include <iostream> #include <vector> using namespace std; template<typename T> struct List { struct Node { Node *prev, *next; T data; Node(Node* prev = nullptr, Node* next = nullptr, T data = T()) : prev(prev), next(next), data(data) { } }; Node *head, ...
752
Project_CodeNet
2,019
#include<bits/stdc++.h> using namespace std; #define call_from_test #ifndef call_from_test #include<bits/stdc++.h> using namespace std; using Int = long long; #endif //BEGIN CUT HERE template<typename Node, size_t LIM> struct BBSTBase{ using u32 = uint32_t; u32 xor128(){ static u32 x = 123456789; static u3...
1,637
Project_CodeNet
2,018
/* -*- coding: utf-8 -*- * * 2890.cc: Pivots */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility...
1,086
Project_CodeNet
2,019
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "unordered_map" #include "unordered_set" #include "iomanip" #include "cmath" #include "random" #include "bitset" #include "cstdio" ...
650
Project_CodeNet
2,018
#include<iostream> #include<vector> using namespace std; int n,Q; struct p{ int l,r; p*next; }; main() { cin>>n>>Q; vector<int>a(n),id(n); for(int i=0;i<n;i++) { cin>>a[i]; id[--a[i]]=i; } p*root=(p*)calloc(1, sizeof(struct p)); root->l=0,root->r=n; for(int i=0;i<Q;i++) { int q;cin>>q;q--; p*now=root...
438
Project_CodeNet
2,018
#include<iomanip> #include<limits> #include<thread> #include<utility> #include<iostream> #include<string> #include<algorithm> #include<set> #include<map> #include<vector> #include<stack> #include<queue> #include<cmath> #include<numeric> #include<cassert> #include<random> #include<chrono> #include<unordered_map> #includ...
731
Project_CodeNet
2,018
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 99999999999999999 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; #define NUM 100005 struct LIST{ int next_value,pre_value; }; LIST info[NUM]; //★★インデックスではなく値基準★★ in...
586
Project_CodeNet
2,018
#include<bits/stdc++.h> using namespace std; const int MAXN = 100010; int main(){ int n,q; cin >> n >> q; int a[n+1]; for(int i=0;i<n;i++){ cin >> a[i]; } int pos[n+1], push_i = n, begin_i = 0; for(int i=0;i<n;i++) pos[a[i]] = i; int query; for(int i=0;i<q;i++){ ...
202
Project_CodeNet
2,018
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #...
2,951
Project_CodeNet
2,018
object Main extends App { import scala.io.StdIn._ val Array(n, q) = readLine.trim.split(' ').map(_.toInt) var nums= readLine.trim.split(' ').map(_.toInt).map{value ⇒ new BiList(value, None, None)}.let{a ⇒ for (i ← 1 until a.length){ a(i - 1).next = Some(a(i)) a(i).prev = Some(a(i - 1)) } ...
557
Project_CodeNet
2,018
/// Thank you tanakh!!! /// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let m...
796
Project_CodeNet
2,019
// AOJ 2890: Pivots // 2019.2.22 bal4u #include <stdio.h> #include <stdlib.h> #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { int n = 0, c = gc(); do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0'); return n; } int ...
516
Project_CodeNet
2,020
#include <stdio.h> int pre[100010],nex[100010]; int main(){ int n,q; scanf("%d%d",&n,&q); int b=0; for(int i=0;i<n;i++){ int t; scanf("%d",&t); nex[b]=t; pre[t]=b; b=t; } nex[b]=n+1; pre[n+1]=b; while(q--){ int x; scanf("%d",&x); if(pre[x]==0){ nex[0]=nex[x]; pre[nex[x]]=0; nex[x]=n+...
361