Guys please help i do all my effort and thinking but i checked 40 testcase my code giving right answer but if get fails in codechef please help me friends
#include
using namespace std;
#include<bits/stdc++.h>
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int start=0;
int end=n-1;
int flag=1; //assume the already rainbow
while(start<=end)
{
if(arr[start]!=arr[end] || arr[start]>7 || arr[end]>7)
{
flag=0;
break;
}
start++;
end--;
}
if(flag==0)
cout<<"no"<<"\n";
else
cout<<"yes"<<"\n";
}
return 0;
#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
int n,flag=0;
cin>>n;
int a[n];
int y[7]={0};
for(int i=0;i<n;i++){
cin>>a[i];
if(a[i]==1||a[i]==2||a[i]==3||a[i]==4||a[i]==5||a[i]==6||a[i]==7)
y[a[i]-1]=1;
}
for(int i=0;i<7;i++){
if(y[i]==0){
flag=1;
// cout<<“error pos1”;
break;
}
}
for(int i=0;i<n/2 && !flag;i++){
if(a[i]!=a[n-i-1]){
flag=1;
// cout<<“error pos2”;
break;
}
}
if(flag==1)
cout<<“no”<<endl;
else
cout<<“yes”;
}
}
so that was my code ,can someone please point out why I am unable to get AC ?
for ( int i = 0; i < 7; i++ ) {
if ( v[i].first != i + 1 ) {
puts("no");
return 0;
}
}
for ( int i = 7; i < 13; i++ ) {
if ( v[i].first != 13 - i || v[i].second != v[12 - i].second ) {
puts("no");
return 0;
}
}
can someone explain me this?
This is my accepted solution for this question on Codechef
#include <bits/stdc++.h>
using namespace std;
int main()
{
long t;
cin>>t;
while(t–)
{
long n;
cin>>n;
int p[n],flag=1,i;
for(i=0;i<n;i++)
cin>>p[i];
int chec[8]={0};
int main() {
int T;
scanf("%d", &T);
assert(T >= 1 && T <= MAX);
while (T–) {
int n;
scanf("%d", &n);
assert(n >= 1 && n <= MAX);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
assert(a[i] >= 1 && a[i] <= MAX);
}
vector<pair<int, int> > cnts;
int cnt = 1, which = a[0];
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
cnt++;
} else {
cnts.push_back(make_pair(which, cnt));
which = a[i];
cnt = 1;
}
}
if (cnt > 0) {
cnts.push_back(make_pair(which, cnt));
}
int ok = true;
// cnt dentoes consecutive groups of equal numbers.
if (cnts.size() == 13) {
for (int i = 0; i < 13; i++) {
if (cnts[i] != cnts[13 - i - 1]) {
ok = false;
}
if (i < 7 && cnts[i].first != i + 1) {
ok = false;
}
}
} else {
ok = false;
}
puts(ok ? “yes” : “no”);
}
return 0;
}
Now Test case i have used is this
1
13
3 4 5 6 1 2 7 2 1 6 5 4 3
My accepted solution is giving yes for above test case while Author’s solution giving no for the same…
I have run several hundreds of codes of other people also for the same test case.Their answer is yes for above test .
But Editorial and Tester solution is giving no for the same.
Just want to ask Codechef Admins what is happening here .Even the guys who have made the question have not used the correct test cases for checking solutions.