Rating changes for the last round are temporarily rolled back. They will be returned soon. ×

### electro177's blog

By electro177, history, 6 days ago, A big binary number

You are given a number n. Find the decimal value of the number that is formed by concatenating the binary representations of the first n positive

Integers. Print the answer modulo 10^9 +7.

Example

Consider N = 2:

The binary representation of 1 is 1.

• The binary representation of 2 is 10

. So the number form after concatenation is 110. in decimals this is equivalent to 6.

n<1e9;

Some help what to do

By electro177, history, 2 weeks ago, hello friends

Is there any way or stl trick to convert vector to vector but there should'nt be any equal elements eg)

[[1,1,6],[1,2,5],[1,2,5],[1,7],[1,7],[2,6]]

to

[[1,1,6],[1,2,5],[1,7],[2,6]]

for vector there exist a std::unique but for this case what to do :) #stl,
By electro177, history, 3 weeks ago, Using set implementation it is working.but using vector the code gives some mingw error which i cannot understand.can anyone know what to do in order to make it work in vectors

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN = 2e5;
int n;
ar<int, 3> a[mxN];

int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i] >> a[i] >> a[i];
}
sort(a, a + n);
set<ar<ll, 2>> dp;
dp.insert({0, 0});
ll ldp = 0;
for (int i = 0; i < n; ++i) {
auto it = dp.lower_bound({a[i]});
--it;
ldp = max(ldp, (*it) + a[i]);
dp.insert({a[i], ldp});
}
cout << ldp;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN = 2e5;
int n;
ar<int, 3> a[mxN];

int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i] >> a[i] >> a[i];
}
sort(a, a + n);
vector<ar<ll, 2>> dp;
dp.push_back({0, 0});
ll ldp = 0;
for (int i = 0; i < n; ++i) {
auto it = lower_bound(dp.begin(), dp.end(), a[i]) ;
--it;
ldp = max(ldp, (*it) + a[i]);
dp.push_back({a[i], ldp});
}
cout << ldp;
} By electro177, history, 4 weeks ago, Hello folks ,Could you share how to stop addicted from something which u are already addicted at,I feel many of you have diffrent techniques for it.please share .it will be useful for other coders out there as well By electro177, history, 4 weeks ago, const int mxN = 2e5;
int n, d[mxN], ans;

void dfs(int u = 0, int p = -1) {
for (int v : adj[u]) {
if (v == p)
continue;
dfs(v, u);
ans = max(d[u] + d[v] + 1, ans);
d[u] = max(d[u], d[v] + 1);
}
}


ans gives the diameter of the tree .It is not that trivial to understand for me.can someone explain please explain how the code works tree,
By electro177, history, 5 weeks ago, #include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define ar array

const int mxa = 1e5 + 1;
ll a, b, c, n, m;
ll dist[mxa];

int main() {

cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a >> b >> c; --a, --b;

}

memset(dist, 0x3f, sizeof(dist));

priority_queue< ar<ll, 2>  , vector<ar<ll, 2>>, greater<ar<ll, 2>> > pq;
dist = 0;
pq.push({0, 0});
while (pq.size()) {

ar<ll, 2> node = pq.top();
pq.pop();

if (node > dist[node])continue;

for ( ar<ll, 2> child : adj[node]) {

if (dist[child] > node + child) {
dist[child] = node + child;
pq.push({dist[child], child});
}
}

}

for (int i = 0; i < n; i++) cout << dist[i] << " ";

}


I have implemented code for Dijstra ,but it finds only min distance of each node from source node. could anyone please help how to retace the shortest path in this approach .Thank you help,
By electro177, history, 5 weeks ago, priority_queue<ar<ll, 2>, vector<ar<ll, 2>>, greater<ar<ll, 2>>> pq;
pq.push({0, 0});
memset(d, 0x3f, sizeof(d));
d = 0;
while (pq.size()) {
ar<ll, 2>    u = pq.top();
pq.pop();

if ( u   > d[ u ] ) // i have a doubt here
continue;

for (ar<ll, 2> v : adj[u]) {

if (d[v] > u + v) {
d[v] = u + v;
pq.push({d[v], v});
}

}
}


I do not understand why if ( u  > d[ u ] ) continue; in the code .please give the reason ,is it related to connected component? By electro177, history, 5 weeks ago, while this is working fine ~~~~~ Your code here... bool emp (int i, int j) { if ( i >= 0 && i < n && j >= 0 && j < m && s[i][j] == '.' )return 1; else return 0;

} ~~~~~

this is giving run time error ~~~~~ Your code here...

bool emp (int i, int j) { if ( s[i][j] == '.' && i >= 0 && i < n && j >= 0 && j < m )return 1; else return 0;

} ~~~~~

does anyone know the reason By electro177, history, 6 weeks ago, I was doing problem towers.I sorted all the blocks according to weight + strength from exchange arguments and then now i did not get idea how to do transitions in dp ,but i saw some code and i thought i should do it by weights from 0 to total weight (but i do not know why) and the transition was

Your code here...

for (auto block : blocks) {
int w = block.w, s = block.s; ll v = block.v;
for (int i = w + s; i >= w; i--)
dp[i] = max(dp[i], dp[i - w] + v);
}


Please help me how to take the dp state and also the transitions mainly(i did not understand after thinking a lot) Thank you # dp,
By electro177, history, 7 weeks ago, this template is not working in my sublime text

Your code here...
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
return os << '{' << p.first << ", " << p.second << '}';
}

template < class T, class = decay_t<decltype(*begin(declval<T>()))>,
class = enable_if_t < !is_same<T, string>::value >>
ostream & operator<<(ostream &os, const T &c) {
os << '[';
for (auto it = c.begin(); it != c.end(); ++it)
os << &", "[2 * (it == c.begin())] << *it;
return os << ']';
}
//support up to 5 args
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_0(_CALL, ...)
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
_NTH_ARG(dummy, ##__VA_ARGS__, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1, _FE_0)     \
(MACRO, ##__VA_ARGS__)
//Change output format here
#define out(x) #x " = " << x << "; "
#define dbg(...)                                                              \
cerr << "Line " << __LINE__ << ": " FOR_EACH_MACRO(out, __VA_ARGS__) << "\n"


 ~~~ ~~~~~

but this is working

Your code here..

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif help,
By electro177, history, 7 weeks ago, I have beem trying this for 2 days but i could not get idea nor understand solutions,could someone please explain it clearly ,i need your help (https://atcoder.jp/contests/dp/tasks/dp_o) someone help please:) # dp,
By electro177, history, 2 months ago, with all type int ,it is accepted ,while with all long long it gives run time error,I thought of always using long long because it is helpful, can u please say when to not use long long

( run time error)//////

# include

using namespace std;

# define ll long long

void task() { ll n,target; cin >> n >> target; vector price(n), pages(n); for (ll&v : price) cin >> v; for (ll&v : pages) cin >> v;

vector<vector> dp(n + 1, vector(target + 1, 0));

// dp = 0;

rep(i, 1, n) { rep(j, 0, target) {

dp[i][j] = dp[i - 1][j];
int left = j - price[i - 1];
if (left >= 0)
dp[i][j] = max(dp[i][j] ,  dp[i - 1][j - price[i - 1]] + pages[i - 1] );

}

}

cout << dp[n][target] << '\n'; }

int main() { int case = 1 ;

for (int i = 0; i < case; i++) task(); }

(accepted)//////

# include

using namespace std;

# define ll long long

void task() { int n, target; cin >> n >> target; vector price(n), pages(n); for (int&v : price) cin >> v; for (int&v : pages) cin >> v;

vector<vector> dp(n + 1, vector(target + 1, 0));

// dp = 0;

rep(i, 1, n) { rep(j, 0, target) {

dp[i][j] = dp[i - 1][j];
int left = j - price[i - 1];
if (left >= 0)
dp[i][j] = max(dp[i][j] ,  dp[i - 1][j - price[i - 1]] + pages[i - 1] );

}

}

cout << dp[n][target] << '\n'; }

int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int case = 1 ; for (int i = 0; i < case; i++) task(); } By electro177, history, 2 months ago, I thought about it for a long time and i am cleearly commenting the code to help understand it easily

i cannot code it here properly for some reason ,so check my submission By electro177, history, 3 months ago, Hello codeforces community ,many of you here are motivated and working towards your goals which is great ,but not all .I am distracted by something or the other .I am addicted to some shitty websites like omegle and some other .But I want to be a good guy and a good coder ,what are the best personal experience of defeating any addiction .please help me and some others like me .addictions can be too dangerous :( . I have already tried to focus many times but could not able to do that. that's why i am asking your help. it can be soo silly but this is most serious issue. good,
By electro177, history, 3 months ago, Hello codeforces, I am currently practicing dp and not getting questions contiously. I am feeling like not doing anything. How to be motivated while doing cp, I don't have any cp friend also. I think this will affect life in general By electro177, history, 3 months ago, omegle website is the place to meet new boys and girls (i got a gf from there ).And it acts as entertainment .you can show ur cp skills(logical) there too.it is the best website other than codeforces i ever saw.what do u think .if u did not try it yet google omegle.com #fun,
By electro177, history, 7 months ago, This award goes to tourist because of the insane hard work and genius . You can refer (https://youtu.be/nfAnKzyiKTo) Salute to your work man. By electro177, history, 7 months ago,  