Codeforces Round 956 (Div. 2) || Editorial for Problem A,B,C,D
HTML-код
- Опубликовано: 12 сен 2024
- A. Array Divisibility || B. Corner Twist || C. Have Your Cake and Eat It Too || D. Swap Dilemma
contest URL: codeforces.com...
Contact me:-
LinkedIn - / swapnil-tayal-53a5b4221
Instagram - / swapnil_tayal
#codeforces #cp #cpp #educational #EducationalCodeforces #div2 #codeforcessolutions #editorial #educational #Codeforces956 #956
Lovely explanation for B
@@ritishrai581 thanks ✨
C solution:
void solve(){
int n;
cin>>n;
int tot=0;
vector a(3, vector(n));
for(int i=0;ia[i][j];
if(i==0) tot+=a[i][j];
}
}
int target=(tot+2)/3;
vi v={0,1,2};
vi ans(6);
do{
int j=0;
int sum=0;
while(j
Bohot badhiya code he bhai tq❤
thanks bro
2nd question intuition was very good
❤❤
try debug it
Bro i write this code for problem C similar to your intution my code is running for test case 1 and failed at test case 2 of (47) which is not showing can you indentify my mistake
// Online C++ compiler to run C++ program online
#include
using namespace std;
int solve(int arr[], int brr[], int i,int n, int &ans, int total)
{
int d=0;
int e=0;
int a2=n;
int b2=n;
int ran1=0;
int ran2=0;
for(int k=i;k=total && ran1==0)
{
a2=k;
ran1++;
}
if(e>=total && ran2==0)
{
b2=k;
ran2++;
}
}
if(a2==n && b2==n)
{
return 0;
}
int sum=0;
for(int j=a2+1;j=total)
{
ans=a2;
return 1;
}
sum=0;
for(int j=b2+1;j=total)
{
ans=b2;
return 2;
}
return 0;
}
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
int b[n];
int c[n];
int sum=0;
for(int i=0;i>a[i];
sum+=a[i];
}
for(int i=0;i>b[i];
}
for(int i=0;i>c[i];
}
int total= (sum+2)/3;
int x=0;
int y=0;
int z=0;
int a1=n;
int b1=n;
int c1=n;
int cnt1=0;
int cnt2=0;
int cnt3=0;
for(int i=0;i=total && cnt1==0)
{
a1=i;
cnt1++;
}
if(y>=total && cnt2==0)
{
b1=i;
cnt2++;
}
if(z>=total && cnt3==0)
{
c1=i;
cnt3++;
}
}
int ans=0;
if(solve(a,b,c1+1,n,ans,total))
{
if(solve(a,b,c1+1,n,ans,total)==1)
{
if(ans
try debug it