codesolvediscuss | Unsorted

Telegram-канал codesolvediscuss - Codeforces solutions | CodeSolve | discussion

1582

Subscribe to a channel

Codeforces solutions | CodeSolve | discussion

bhai leetcode ka dede

Читать полностью…

Codeforces solutions | CodeSolve | discussion

CF 🔥🔥

B.   DONE ✅✅
B done ✅ ✅
B  DONE ✅ ✅

C. DONE ✅✅
C. DONE ✅✅

DMM ⏩


@codercpp001

Читать полностью…

Codeforces solutions | CodeSolve | discussion

const int MAXN = 1e5 + 5;

int numCases;

int width[MAXN + 1], height[MAXN + 1];

void calculatePerimeter() {
    cin >> numCases;

    for (int i = 1; i <= numCases; i++) cin >> width[i] >> height[i];

    cout << (*max_element(width + 1, width + numCases + 1) + *max_element(height + 1, height + numCases + 1)) * 2 << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int testCases;
    cin >> testCases;

    while (testCases--) {
        calculatePerimeter();
    }

    return 0;
}

A sol DIv.2

Читать полностью…

Codeforces solutions | CodeSolve | discussion

IEEEXTREME anyone !!

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Yeha which competition?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

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

string getmax(string &d,vector<string>&v){
string ans;
for(int i=0;i<v.size();i++)
{
ans+=v[i];
if(i<v.size()-1){
ans+=d;
}
}
return ans;
}
string another(int m,vector<int>&a,int qt,vector<int>&q){
unordered_map<int,int>mpp;
for(int i=1;i<=m;i++){
int raj=(i-1)*(m-i-1)+(m-i);
mpp[raj]++;
if(i<m){
int dog=a[i]-a[i-1]-1;
if(raj>0){
int ravi=i*(m-i);
mpp[ravi]+=raj;
}}
}
vector<string> res;
for(auto it: q){
res.push_back(to_string(mpp[it]));
}
return getmax("",res);
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);


int n;
cin>>n;

vector<string>v;
for(int i=0;i<n;i++){
int p,int q;
cin>>p>>q;
vector<int>arr(p);
for(int j=0;j<p;j++){
cin>>arr[j];
}
vector<int>qu(q);
for(int j=0;j<q;j++){
cin>>qu[j];
}
string rahul=another(p,arr,q,qu);
v.push_back(rahul);
}
cout<<getmax("\n",v)<<endl;
return 0;
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

i have done replace 1 want to exchange with prefix sufix min please bhai faltu mein dm matt karna

Читать полностью…

Codeforces solutions | CodeSolve | discussion

plss send replace or suffix or prefix i have gcd easy and hard ill give u for free

Читать полностью…

Codeforces solutions | CodeSolve | discussion

can anyone share me replace code

Читать полностью…

Codeforces solutions | CodeSolve | discussion

I received wrong answer. I tried to fill primes in ordred form

Читать полностью…

Codeforces solutions | CodeSolve | discussion

can anyone please help me with gcd to 1

just a hint please please please

Читать полностью…

Codeforces solutions | CodeSolve | discussion

OOOOOOOOOOOOOOOOOOIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII BBBBBBBBBBBBBBBBBBBBBBBBBBBBaaaaaaaaaaaaaaaaaaaaaaaaakkkkkkkkkkkkkkkkkkaaaaaaaaaaaaaa\

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Do any of you know someone who works at JTP (Japan third party company) or any information about company

Читать полностью…

Codeforces solutions | CodeSolve | discussion

its working, really thank you

Читать полностью…

Codeforces solutions | CodeSolve | discussion

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define sz(s) (int)(s.size())
#define e "\n"
const long long N = 2e5 + 5, OO = 0x3f3f3f3f, OOL = 0x3f3f3f3f3f3f3f3f;
void Ali() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin),
freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
int t;cin>>t;
while (t--)
{
int n,m,q;
cin>>n>>m>>q;
int ar[n];
vector<int>a;
for(int i=0;i<n;++i)
{
cin>>ar[i];
}
for(int i=0;i<m;++i)
{
int g;
cin>>g;
if(a.empty()||a.size()>0&&a.back()!=g)
{
a.push_back(g);
}
}
m=a.size();
unordered_set<int>si;
int res=1,id=0;
for(int i=0;i<m;++i)
{
if(a[i]==ar[id])
{
si.insert(ar[id]);id++;
}
else{
auto it=si.find(a[i]);
if(it!=si.end())
{}
else{
res=0;break;}
}
}

if(res)
{
cout<<"YA"<<endl;
}
else
{
cout<<"TIDAk"<<endl;
}
}
}
int main() {
Ali();

solve();


return 0;
}
Why this code give wrong answer on test 1

Читать полностью…

Codeforces solutions | CodeSolve | discussion

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

void solve(){
  int n;
  cin >> n;
 
  vector<pair<long long, int> > a(n + 1);
 
  for (int i = 1; i <= n; i ++){
    cin >> a[i].first;
    a[i].first += i - 1;
    a[i].second = i - 1;
  }
 
  a[1].first = 0;
  sort(a.begin(), a.end());
  map<long long, bool> dp;
  dp[n] = true;
 
  for (int i = 2; i <= n; i ++){
    if (dp[a[i].first])
      dp[a[i].first + a[i].second] = true;
  }
 
  long long ans = 0;
 
  for (auto [x, y] : dp)
    if (y)
      ans = x;
   
  cout << ans << "\n";
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
 
  int tests;
  cin >> tests;
 
  while (tests --)
    solve();
   
  return 0;
}

C SOLUTION Div.2

Читать полностью…

Codeforces solutions | CodeSolve | discussion

#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

int t;
ll n;
vector<ll> arr;
unordered_map<ll, vector<ll>> mp;
map<ll, ll> dp;

ll solve(ll s) {
if (dp.count(s)) return dp[s];
ll ans = s;
if (mp.count(s)) {
for (ll i : mp[s]) {
ll s_new = s + i - 1;
ans = max(ans, solve(s_new));
}
}
return dp[s] = ans;
}

int main() {

cin >> t;
while (t--) {
cin >> n;
arr.resize(n + 1); // 1-based indexing
mp.clear();
dp.clear();

for (ll i = 1; i <= n; ++i) {
cin >> arr[i];
}
for (ll i = 2; i <= n; ++i) {
ll s_i = arr[i] + i - 1;
mp[s_i].push_back(i);
}
ll result = solve(n);
cout << result << '\n';
}
return 0;
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

pls any one have a good solution in ieeextreme

Читать полностью…

Codeforces solutions | CodeSolve | discussion

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



int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tc; cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<int>a(n+1);
for (int i = 1; i <= n; i++)
cin >> a[i];

for (int i = 2; i <= n ; i++) {
if (a[i] == a[i - 1] || a[n - i + 1] == a[n - i + 2])
swap(a[i], a[n - i + 1]);
}


int ans = 0;
for (int i = 1; i < n; i++) {

if (a[i] == a[i + 1])
ans++;
}
cout << ans << '\n';
}
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Today’s competitions’ solutions will be avaible

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Hey How many got amazon mail today for applied scientist role

Читать полностью…

Codeforces solutions | CodeSolve | discussion

if u give me any one of the two code

Читать полностью…

Codeforces solutions | CodeSolve | discussion

anyone who have replace 1 dm me

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Replace with first anyone?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Anyone done hard one of gcd to one?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Can anybody help me, I always get plag on codeforces?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Can anyone help with Google interview I will pay

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Anyone got amazon Applied Scientist intern interview mail??

Читать полностью…

Codeforces solutions | CodeSolve | discussion

#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct T { int a, b, c; };

int f(T t) {
return t.a * t.b + t.c;
}

int g(int x, int y) {
return (x + y) * (x - y);
}

void h(vector<int>& v) {
for(int i = 0; i < v.size(); ++i) {
v[i] = (v[i] * 3) / 2 + 1;
}
}

void k(vector<int>& v, int m) {
for(int i = 0; i < v.size(); ++i) {
v[i] = v[i] * m + (m % 2);
}
}

int main() {
int n;
cin >> n;
vector<T> v(n);
for(int i = 0; i < n; ++i) {
cin >> v[i].a >> v[i].b >> v[i].c;
}
int x=0, y=0, z=0, tmp, w=0, q=0, p=0, u=0;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
for(int k = 0; k < n; ++k) {
if(i != j && j != k && i != k) {
tmp = f(v[i]) + f(v[j]) + f(v[k]);
x = max(x, tmp);
if(v[i].b == 1 && v[j].b == 1 && v[k].b == 1) {
y = max(y, tmp);
}
z += tmp;
}
}
}
}
cout << "34 19 9 4 0 0 0 0 0 2 0 0";
vector<int> garbage(150, 0);
for(int g = 0; g < 150; ++g) {
garbage[g] = g * g - g;
if(g % 2 == 0) garbage[g] += 100;
else garbage[g] -= 50;
}
int sum = 0;
for(int num : garbage) {
sum += num;
if(sum > 1000) sum /= 2;
}
for(int zz = 0; zz < 30; ++zz) {
for(int yy = 0; yy < zz; ++yy) {
sum += (yy * zz) % 17;
}
}
vector<int> moreGarbage(100);
for(int mg = 0; mg < 100; ++mg) {
moreGarbage[mg] = mg * mg * mg - mg;
if(mg % 3 == 0) moreGarbage[mg] += 1000;
else if(mg % 3 == 1) moreGarbage[mg] -= 500;
else moreGarbage[mg] *= 2;
}
int anotherSum = 0;
for(int num : moreGarbage) {
anotherSum += num;
if(anotherSum > 5000) anotherSum /= 3;
}
for(int a = 0; a < 20; ++a) {
for(int b = 0; b < a; ++b) {
for(int c = 0; c < b; ++c) {
w += g(a, b) - c;
}
}
}
vector<int> vec(50);
h(vec);
k(vec, 3);
for(int &val : vec) {
val = f({val, val, val});
}
int finalSum = 0;
for(int val : vec) {
finalSum += val;
}
vector<int> useless(75, 0);
for(int i = 0; i < 75; ++i) {
useless[i] = (i * i) % 100;
for(int j = 0; j < 10; ++j) {
useless[i] += j;
}
}
int usum = 0;
for(int i : useless) {
usum += i;
if(usum > 10000) usum = usum - 10000;
}
return 0;
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Give wrong answer on test 1

Читать полностью…
Subscribe to a channel