Codeforces|Leetcode|Codechef free solutions
Ir al canal en Telegram
Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.
Mostrar más4 317
Suscriptores
Sin datos24 horas
-137 días
-5230 días
Archivo de publicaciones
Code with cisco limited slots left Dm @Cpsoln fast🔥🔥🔥
If you want help in any company oa today then Dm @Cpsoln
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<pair<int,int>,int> M;
int timer;
pair<int,int> find(int ind,vector<vector<int>> &adj,vector<int> &H,int par){
if(H[ind]!=-1){
return {H[ind],0};
}
timer++;
H[ind] = timer;
int res = H[ind],sum = 1;
for(auto &val:adj[ind]){
if(val==par) continue;
pair<int,int> P = find(val,adj,H,ind);
int x = P.first,y = P.second;
sum+=y;
if(x<=H[ind]){
res = min(res,x);
}
else{
M[{ind,val}] = y;
}
}
H[ind] = res;
return {res,sum};
}
signed main()
{
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
vector<vector<int>> adj(n);
while(m--){
int u,v;
cin>>u>>v;
u--;
v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
M.clear();
timer = 0;
vector<int> H(n,-1);
pair<int,int> P = find(0,adj,H,-1);
int ans = n*(n-1)/2;
for(auto &val:M){
int l = val.second,r = n - val.second;
ans = min(ans, (l*(l-1) + (r*(r-1)))/2);
}
cout<<ans<<endl;
}
return 0;
}
void solve(int ttc){
int n,k;
cin>>n>>k;
vi a(n);
fill(a);
map<int,set<int>>mp;
for(int x:a){
if(mp[x%k].find(x)!=mp[x%k].end()){
mp[x%k].erase(x);
}else{
mp[x%k].insert(x);
}
}
int cnt=0,val=-1;
for(auto x:mp){
int sz=x.S.size();
if(sz%2){
cnt++;
val=x.F;
}
}
if(cnt>1){
cout<<-1<<endl;
return;
}
int ans=0;
bool flg=false;
for(auto x:mp){
if(x.F==val){
continue;
}
while(x.S.size()>0){
int b=*x.S.begin();
x.S.erase(b);
int tp=*x.S.begin();
ans+=(tp-b)/k;
x.S.erase(tp);
}
}
//deb(ans);
if(cnt){
vi v;
for(int x:mp[val]){
v.pb(x);
}
//pv(v);
int n=v.size();
if(n==1){
cout<<ans<<endl;
return;
}
vi pref(n,0),suf(n,0);
pref[1]=v[1]-v[0];
for(int i=3;i<n-1;i++){
pref[i]=v[i]-v[i-1]+pref[i-2];
}
suf[n-2]=v[n-1]-v[n-2];
for(int i=n-4;i>=0;i--){
suf[i]=v[i+1]-v[i]+suf[i+2];
}
int ta=LLONG_MAX;
for(int i=0;i<n;i+=2){
int x=0;
if(i>0){
x+=pref[i-1];
}
if(i+1<n){
x+=suf[i+1];
}
ta=min(ta,x);
}
ans+=ta/k;
}
cout<<ans<<endl;
}
Don't do these things I am tired from morning I was doing leetcode then Amazon slots and then I have to do codeforces.
So please pareshan matt karo yarr🥹
One guy just now gave me a edited screenshot and he is only telling that I have done scam😂
Pls guys don't frustrate me by paying through different fake apps and just showing edited screenshot of payment I can easily check what is genuine and what is not.
