text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; ... |
#include <iostream>
#include <vector>
using namespace std;
int main() {
int l;
cin >> l;
int n = 1;
while ((1 << n) <= l) {
n++;
}
vector<int> a(0), b(0), c(0);
for (int i = 0; i < n - 1; i++) {
a.push_back(i);
b.push_back(i + 1);
c.push_back(0);
... |
#include<iostream>
#include<vector>
using namespace std;
vector<int> u;
vector<int> v;
vector<int> w;
int main() {
int L;
cin >> L;
int r = 1, r_count = 0, M = 0;;
while (r * 2 <= L) {
r *= 2;
r_count++;
}
int N = r_count + 1, length = 1;
for (int i = 1; i <= r_count; i++) ... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
#define lowbit(x) ((x)&-(x))
int x;
int n,m;
vector<pair<pair<int,int>,int> > v;
int main(int argc, char const *argv[]){
while(~scanf("%d",&x)){
v.clear();
n = 1;
int tmp = x;
while(tmp - lowbit(tm... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,t... |
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
long l;
cin >> l;
long r;
for (r=1;r<=19;++r) {
if (l < pow(2,r)) {
break;
}
}
--r;
vector<vector<long>> ans;
for (long i=1;i<=r;+... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];
int main()
{
ll n;
cin >> n;
ll bi[20]={};
ll max,sum,coun=0;
rep(i,20){
if(((n>>i)&1LL)==1){
bi[i]++;
max=i;
... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
int main(){
int l;
cin>>l;
if(l==2){
cout<<"2 2\n1 2 0\n1 2 1"<<endl;
return 0;
}
int n;
for(int i=19;i>=0;i--){
if((l-1)&(1<<i)){
n=i+1;
br... |
#include<bits/stdc++.h>
using namespace std;
struct f{
int a,b,c;
};
int main(){
int o;
cin>>o;
vector<f> e;
int r=log2(o);
int n=r+1;
for(int i=0;i<r;i++){
e.push_back(f{i+1,i+2,0});
e.push_back(f{i+1,i+2,1<<i});
}
int p=1<<r;
for(int i=r;i>=1 && o-p>0;i--){
int w=1<<(i-1);
if(o-p>=w){
o-=w;
e.... |
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define ML 1000005
using namespace std;
struct EDGE
{
int u, v, w;
EDGE (const int& nu = 0, const int& nv = 0, const int& nw = 0) : u(nu), v(nv), w(nw) {}
} E[66];
int N = 0, M = 0, L;
int main()
{
int mxp = 0;
scanf("%d", &L);
if(L =... |
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int L; cin >> L;
int N = 2, p = 2;
while (p * 2 <= L) {
N++;
p *= 2;
}
int M = (N - 1) * 2 - 1;
int l = L;
while (l) {
M += l % 2;
l /= 2;
}
cout <... |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;
// ref... |
#include <iostream>
#include <vector>
using namespace std;
int main() {
int l;
cin >> l;
int n = 20;
vector<vector<int>> ret;
for (int i = 2; i < n; i++) {
ret.push_back({i, i + 1, 0});
ret.push_back({i, i + 1, 1 << n - 1 - i});
}
for (int i = 2; i <= n; i++) {
in... |
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000
//using namespace atcoder;
using namespace std;
int main(void){
ll l;
cin >> l;
ll n = 0;
while ((1 << n) <= l){
n++;
}
vector<tuple<ll,ll,ll>> m(0... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
vector<int> getBit(int n){
vector<int> ret;
while(n){
ret.push_back(n&1);
n >>= 1;
}
reverse(ret.begin(), ret.end());
return ret;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(N... |
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
int L;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); co... |
#include <bits/stdc++.h>
using namespace std;
struct edge {
int from;
int to;
int len;
};
int main() {
int l;
cin >> l;
int r = 0;
for ( int i = 1; i*2 <= l; i*=2 ) { r++; }
int r2 = 1 << r;
if ( r > 19 ) { r = 19; }
int n = r+1;
vector<edge> es;
for ( int i = 1; i < n; i++ ) {
edge t;
... |
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<math.h>
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define ll long long
using namespace std;
int l;
struct nod
{
int to,val;
};
vector<nod>g[25];
int main()
{
int n=0,m=-1;
scanf("%d",&l)... |
#include <iostream>
#include <cstring>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
int l, b = 1, cnt = 0;
vector<int> u, v, w;
cin >> l;
while (b <= l) {
b *= 2; cnt++;
}
for (int i = 1; i ... |
#include <cstdio>
using namespace std;
int a[300],b[300],c[300];
int m;
void push(int aa,int bb,int cc){
m++;
a[m]=aa;
b[m]=bb;
c[m]=cc;
}
int main() {
int L;
scanf("%d",&L);
L--;
int x=1,n=20;
while(L>=0){
if (L==0){
if (x<n)
push(x,n,0);
... |
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
#define MOD (i... |
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 6... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<tuple<int,int,int>> q;
int main() {
int l;
cin >> l;
int ncnt = 1;
while (pow(2,ncnt)-1 < l) {
ncnt++;
}
int node[ncnt];
for (int i;i < ncnt;i++) {
node[i] = pow(2,i) - 1;
if (i != ncnt-1) {
q.push_back(make_tuple(i+1,i+2,0));... |
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int l;
cin >> l;
int tl = l;
int dl = 0;
bool te[20];
int ce = 0;
memset(te, 0, sizeof(te));
while (l) {
if (l & 1) {
te[dl] = true;
ce++;
}
l >>= 1;
dl++;
... |
#include <bits/stdc++.h>
using namespace std;
struct Edge {
int from, to, cost;
};
int main() {
int l;
cin >> l;
int r = log2(l);
vector<Edge> edges;
int n = r + 1;
for (int i = 0; i < r; i++) {
edges.push_back(Edge{i + 1, i + 2, 0});
edges.push_back(Edge{i + 1, i + 2, 1 << i});
}
int pow_r ... |
#include <bits/stdc++.h>
using namespace std;
struct data {
long long from, to, dis;
};
long long x, n = 0;
vector<data> v;
void solve();
int main() {
cin >> x;
solve();
cout << n << " " << v.size() << endl;
for(int i = 0; i < v.size(); ++i)
cout << v[i].from + 1 << " " << v[i].to + 1 << " "
... |
#include <iostream>
#include <cmath>
using namespace std;
int L;
int M;
int main(void) {
cin >> L;
int N = 1;
int num = 1;
for (;; N++) {
num *= 2;
if (num > L) { break; }
}
cout << N ;
//==================== M
M = 2 * (N - 1);
int A = L - num / 2;
while (A) {
int j = 0;
int m = 1;
for (;;... |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main () {
long L;
vector<string> ans;
cin >> L;
for (int i = 1; i < 20; i++) {
if (L == 1) {
ans.push_back(to_string(i) + " " + to_string(i + 1) + " 0");
continue;
}
if (L % 2 != 0) {
ans.push_back... |
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
int main(){
ll l;
cin>>l;
if(l==2){
cout<<"2 2"<... |
#include"bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
int n = 2;
int m = 2;
map<P, vector<int>> e;
void dfs(int l) {
if (l == 2) {
e[P(1, 2)].push_back(0);
e[P(1, 2)].push_back(1);
} else if (l % 2 == 0) {
dfs(l / 2);
for (auto edge: e) {
P p = edge.first;
for (int i =... |
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int L, L_, N, M, R;
cin >> L;
N = 0;
M = -2;
L_ = L;
while(L_!=0) {
N++;
M += 2;
L_ /= 2;
}
R = L-pow(2,N-1);
for(int i=0; i<N; i++) {
if (R & (1<<i)) {
M++;
}
}
cout << N << " " << M << e... |
#include <bits/stdc++.h>
// #include <atcoder/all>
// #LIB#
using namespace std;
// using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define upd... |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) c... |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
vector<ll>F, T, W;
ll N;
void push(ll f, ll t, ll w){
F.push_back(f);
T.push_back(t);
W.push_back(w);
}
void show(){
cout << N << " " << F.size() << endl;
for(ll i = 0; i < F.size(); i++){
cout << F[i] << " " << T[i] << " "... |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long lo... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int L;
vector<P> G[30]; // const, to
vector<bool> op; // T: x2, F: +1
int s,t,now,e;
void gen_op(int num){
if(num == 2) return;
if(num%2 != 0){
gen_op(num-1);
op.push_back(false);
}else{
gen_op(num/2);
op.push_bac... |
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
using namespace std;
int main()
{
int L;
cin >> L;
int N = (int)log2(L) + 1;
vector<tuple<int, int, int>> v;
for (int i = 1; i <= N-1; i++) {
v.push_back(make_tuple(i, i+1, 0));
v.push_back(make_tuple(i, i+1, 1<<... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
using iii = tuple<int, int, int>;
int l;
void solve() {
int n = 0;
for (int i = 20; i >= 0; i--)
if (l & (1 << i)) { n = i + 1; break; }
vector<iii> edges;
for (int i = 0; i < n - 1... |
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <math.h>
using namespace std;
using ll = long long;
int main()
{
ll a, b = 0, c = 0, d = 0;
ll l;
ll memo[2][100];
cin... |
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
struct edge {
int v1;
int v2;
int c;
};
int main() {
int l; std::cin >> l;
int n = int(log2(l))+1;
std::vector<edge> es;
for (int i = 1; i ... |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main() {
int l;
cin >> l;
vector<string> res = {};
int n = 0;
int pow = 1;
while (pow <= l) {
pow *= 2;
n++;
}
for (int i = 0; i < (n - 1); i++... |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int N;
cin >> N;
int d = 2;
while ((N >> d) != 0) d++;
vector<pair<pair<int, int>, int>> ans;
for (int i = 1; i <= 19; i++) ans.push_back({{i, i+1}, 0});
for (int i = 1; i < d; i++) ans.push_back({{i, i+1}, (1 <<... |
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
st... |
#include<bits/stdc++.h>
using namespace std;
int l;
int main () {
cin >> l;
int n = log2(l) + 1;
int m = __builtin_popcount(l) - 1 + (n - 1) * 2;
int lst = 1;
cout << n << " " << m << endl;
for (int i = 0; i < n - 1; i++) {
cout << i + 1 << " " << i + 2 << " " << 0 << '\n';
cout << i + 1 ... |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;
#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)
int l;
int r;
vector<pii> v;
int main(){
cin >> l;
r = log2(l);
int n = r+1;
int m = 2*r;
l -=... |
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
struct E { int v, w; };
int id(int u) { return... |
#include <bits/stdc++.h>
typedef std::pair<int, int> pii;
int n, m, i, j, k, L, cntE;
std::vector<pii> gra[70];
inline void adde(int u, int v, int w) {
gra[u].push_back(std::make_pair(v, w));
cntE++;
}
int main() {
scanf("%d", &L);
int cntV = 0, _L = L;
while (_L) {
cntV++;
_L >>= 1;
}
... |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PI;
vector<PI> v;
int main()
{
int l;
cin >> l;
int r;
for( r = 0; r <= 19; r++ ) {
if( (1 << (r + 1) ) > l ) {
break;
}
}
int n = r + 1;
for( int i = 1; i < n; i++ ) {
v.push_back(make_pair( make_pair(i, i +... |
#include "bits/stdc++.h"
#include "math.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size();
const int INF=INT_MAX;
struct edg... |
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef struct{
int from,to,cost;
}edge;
int main(void){
int i,n_node=1,n_2=1,L;
cin >> L;
vector<edge> v;
while(2*n_2<=L&&n_node<20){
v.push_back({n_node,n_node+1,n_2});
n_2*=2;
n_node++;
}
... |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int popcount(long long n) { int cnt = 0; for ( ; n; n &= n - 1) cnt++; return cnt; }
int MSB1(long long x) { int d = 0; while ((1LL << d) <= x) d++; return d; }
int main() {
int L; cin >> L;
int n = MSB1(L);
int m = (n - 1) * 2... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int L, N = 0;
vector<vector<int>> edge;
int main(void){
scanf("%d", &L);
while(1 << N <= L) ++N;
for(int i = 1; i < N; ++i){
edge.push_back(... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);
int l;
int n = 20;
vector<tuple<int, int, int>> ans;
int main(void) {
// Here your code !
scanf("%d", &l);
int r;
for (ll i = 1; i <= n; ++i) {
if ((1 << i) > l) {
... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn = 22;
vector< pair<int , int > > adj[mxn];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
int pw[22];
pw[0] = 1;
for(int i = 1; i < 22; i++)
{
pw[i] = pw[i-1] *2;
}
vector< int > vt;
while(... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD = 998244353;
int main() {
int L;
cin >> L;
L--;
int cnt = 0;
int M = 0;
vector<pair<pair<int, int>,int>> ANS(0);
for(int i = 0; i < 20; i++){... |
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
struct edge {
ll src, dst, cost;
edge() {}
edge(ll a, ll b, ll c) : src(a), dst(b), cost(c) {}
};
int main() {
ll L, r = 1;
ll N = 0, M;
vector<edge> G;
cin >> L;
while (r <= L) {
r *= 2;
... |
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
int l;
cin ... |
#include <bits/stdc++.h>
using namespace std;
int l, u[100], v[100], w[100];
int main() {
cin >> l;
int eid = 0, t = 0;
while((1<<t+1) <= l) t++;
for(int i = 1; i <= t; i++) {
u[++eid] = i, v [eid] = i+1, w[eid] = 0;
u[++eid] = i, v [eid] = i+1, w[eid] = (1<<i-1);
}
int r = l-(1<<t), p = (1<<t)-1;
//cout ... |
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
ll log(ll x, ll n){
if(x==1){
return n;
}else{
return log(x/2, n+1);
}
}
ll beki(ll x , ll n){
ll ans = 1;
for(int i = 0; i < n; i++)
{
ans *= x;
}
retu... |
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Edge {
int src, dst, w;
Edge(int _s, int _d, int _w) : src(_s), dst(_d), w(_w) {}
Edge() {}
};
int main() {
cin.tie(0); ios::sync_with_stdio(false);
ll L;
cin >> L;
int d = 0;
for (int p = 2; p <= L; p *= 2)... |
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
int L;
vector<vector<int>> ans;
int r=1,i=1;
cin >> L;
while(2*r<=L){
ans.push_back({i,i+1,0});
ans.push_back({i,i+1,r});
++i;
r*=2;
}
while(r!=L){
int j=... |
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)... |
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
struct edge{ll from,to,weight;};
int vertex,num=1;
vector<edge> g;
vector<in... |
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
int l, ans = 0;
cin >> l;
int n = 1, m = 0;
while((1 << n) <= l) n++;
vector<int> a(n);
vector<string> s;
for(int i = 1; i < n; i++){
int x = 1 << (i - 1);
s.push_back(to_string(i) + " " + to_string(i + 1) + " 0");
s.p... |
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
cin >> L;
vector<tuple<int,int,int>>path;
vector<bool>flag;
while (L != 2) {
if (L & 1) {
L--;
flag.push_back(1);
}
else {
L /= 2;
flag... |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
int main() {
int l;
cin >> l;
int d;
rep(i, 20){
if(1 & (l >> i))d ... |
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
signed main(){
int l;
cin >> l;
int cnt = 0;
... |
#include "bits/stdc++.h"
using namespace std;
int main() {
int L;
cin >> L;
vector<tuple<int,int, int>>Ans;
int N = 2;
int pow = 1;
Ans.push_back(make_tuple(N-1,N,0));
Ans.push_back(make_tuple(N - 1, N, pow));
while (pow*4 -1 < L ) {
pow *= 2;
N++;
Ans.push_back(make_tuple(N - 1, N, 0));
Ans.push_back... |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
struct data {
int from, to;
int cost;
data(int from, int to, int cost): from(from), to(to... |
#include<bits/stdc++.h>
using namespace std;
struct edge
{
int u,v,w;
edge(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
}e[100005];
int main()
{
// freopen("f.in","r",stdin);
// freopen("f.out","w",stdout);
int l,jl1,jl2;
cin>>l;
for(int i=2;(1<<i-1)<=l;i++)
{
jl1=i,jl2=l-(1<<i-1);
}
int n=jl1;
cout<<n<<" ";
i... |
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <co... |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
int l;
cin >> l;
vector<int> sum_pow2{0};
int log2l = 0;
for (int i = 1; i <= l; i *= 2) {
sum_pow2.push_back(sum_pow2.back() + i);
log2l++;
}
int n = log2l, m = (n - 1) * 2;
int cur = l, lim = l, idx = 0;... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
us... |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int l;
cin >> l;
int n = 20;
vector<int> u, v, w;
for(int i = 1; i < 20; i++){
u.emplace_back(i);
v.emplace_back(i + 1);
w.emplace_back(0);
}
int next = 1;
int boundary = 1... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int L;
cin >> L;
int r = 0;
while(L >> (r + 1)) ++r;
int cnt = __builtin_popcount(L) - 1;
cout << r + 1 << ' ' << 2 * r + cnt << endl;
for(int i=0; i<r; ++i) {
cout << i + 1 << ' ' << i + 2 << ' ' << 0 << endl;
cout... |
#include<bits/stdc++.h>
using namespace std;
int main(){
int L;
scanf("%d",&L);
int vtx = 0,cp=L,edg;
vector<int> V; //pos of zeros
for(int it,i=0;(it=1<<i)<=L;i++){
if(it&L)
V.push_back(i); //10000 -> 0(0000~1111), the place of 1->0.
vtx = i+1;
edg = 2*(vtx-1) + ... |
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int f (int x) {
int r = 0;
while (r < 19 and (1 << (r + 1)) <= x) r++;
return r;
}
int main() {
int l;
cin >> l;
const int r = f(l);
vector<pair<P, int>> edge;
for (int v = 0; v < r; v++) {
edge.emplace_back(P(v, v + 1), 0);
edge.em... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;
int power(int n){
int res=1;
rep(i,0,n) res*=2;
return res;
}
int main(){
int l;
cin>>l;
vector<bool> v;
int a=l;
while(a>0){
v.push_back(a%2);
a/=... |
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
long long l;
cin>>l;
int n=floor(log2(l));
//long long dp[n]={};
string ans="";
int m=0;
rep(i,n){
ans+=to_string(i+1)+" "+to_string(i+2)+" 0"+"\n";
m++;
ans+=to_string(i+1... |
#include<bits/stdc++.h>
#define maxn 100005
#define inf (1<<30)
#define mod 1000000007
using namespace std;
typedef long long LL;
int read()
{
char c=getchar();int f=1,sum=0;
while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
return sum*f;
}
int L;
int bit[25]... |
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b)... |
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define N 30
using namespace std;
int n,m,l,now,num[N];
vector<int>son[N],val[N];
int main()
{
int i,j;
cin>>n;
now=n;
for(; n; n/=2)
{
num[++l]=n%2;
}
// reverse(num+1,num+l+1);
// for(i=1;i<=l;i++) cout<<n... |
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
using namespace std;
int main(){
int L;
vector< vector<int> > ans;
int r = 1, i = 1;
cin >> L;
while( 2*r <= L ) {
ans.push_back( {i,i+1,0} );
ans.push_back( {i,i+1,r} );
i++; r*=2;
... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> T;
int main() {
ll L; cin >> L;
ll r = 0;
for (ll i = 0; i < 30; i++) {
if (L >= 1 << i) {r = i;}
}
vector<T> es;
for (ll i = 0; i < r; i++) {
es.push_back(T(i+1,i+2,0));
es.push_back(T(i+1,i+2,1 << i));... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;
struct node {
int u, v, w;
} e[100];
int tot = 0;
int b[100];
int main() {
int l;
scanf("%d", &l);
for (int i = 1; i <... |
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
using namespace std;
typedef long long ll;
const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
int ... |
#include<bits/stdc++.h>
using namespace std;
int main() {
int l;
cin >> l;
int n = log2(l);
vector<tuple<int, int, int>> ans;
for (int i = 0; i < n; i++) {
ans.emplace_back(i + 1, i + 2, 0);
ans.emplace_back(i + 1, i + 2, 1 << i);
}
for (int t = n; t >= 0; t--) {
i... |
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int L,cnt;
int st[61],to[61],cost[61];
int main(){
ios::sync_with_stdio(false);
cin>>L;reg int pos=0;
for(reg int i=20;i&&(!pos);i--)if(L&(1<<i))pos=i;
for(reg int i=1;i<pos;i++){
st[++cnt]=i;to[cnt]=i+1;cost[cnt]=0;
st[++cn... |
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
using namespace std;
typedef long long int ll;
typedef tuple<int,int,int> edge;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
int main(){
... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
struct edge {
int s;
int e;
int w;
edge(int s, int e, int w) {
this->s = s;
this->e = e;
this->w = w;
}
};
... |
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;
int func(int x,int y){
if(y==0)return 1;
int ret = 1;
for(int i=1;i<=y;i++){
ret*=x;
}
return ret;
}
int main(void){
int L;
cin >> L;
int ... |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
struct edge {
ll from, to, val;
};
signed main() {
ll L;
cin>>L;
vector<edge> edges;
ll d = 0;
while ((1ll << (d+1)) <= ... |
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
stru... |
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>
using ll = long long;
using namespace std;
struct edge{int u, v, w;};
int main() {
int l;
cin >> l;
int d = 1 << 20, i = 1;
for ( ; (2 * d & l) == 0; d >>= 1);
vector<edge> ans;
for (... |
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string s;
long long int a[5]={};
string march="MARCH";
for(int i=0;i<n;i++){
cin>>s;
for(int j=0;j<5;j++)
if(s.at(0)==march[j])
a[j]++;
}
long long int ans=0;
for(int i=0;i<3;i++)
for(int j=... |
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_A 2333
#define MAX_L 15
#define int long long
using namespace std;
const char c[]="MARCH";
int n;
int f[MAX_A];
char s[MAX_L];
int cal()
{
int ans=0;
for(int i=0;i<5;i++)
{
for(int j=i+1;j<5;j++)
{
for(int k=j+1;k<5;k++)
{
ans+=... |
#include<iostream>
#include<string>
const char c[5]={'M','A','R','C','H'};
using namespace std;
int main(){
int n;
cin >> n;
string s;
long cnt[5]={0};
for(int i=0;i<n;i++){
cin >> s;
for(int j=0;j<5;j++){
if(s[0]==c[j]) cnt[j]++;
}
}
long long res=0;
for(int i=0;i<5;i++){
f... |
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
int N;
cin >> N;
string S;
char b[5]={'M','A','R','C','H'};
long long a[5]={};
rep(i,N){
cin >> S;
rep(j,5) if(S[0]==b[j]) a[j]++;
}
int c[10]={0,0,0,0,0,0,1,1,1,2};
int d[10]... |
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
int main(){
int N;
ll M=0,A=0,R=0,C=0,H=0;
cin >> N;
vector<char> S;
string tmp;
while(cin >> tmp){
char f=tmp[0];
if(f=='M'){M++;}
else if(f=='A'){A++;}
else if(f=='R'){R++;}
else if(f=='C'){C++;}... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.