gives accurate solution when run with few other test cases but gives WA when submitted as a whole
Difference between en1 and en2, changed 1,318 character(s)
[submission:93347036]↵

My code: for famous digit game problem from latest contest::↵

#include <bits/stdc++.h>↵
using namespace std;↵
#define ll long long↵
#define dd double↵
#define pb push_back↵
 ↵
void accept(int arr[], ll size){for(ll h=0;h<size;h++){cin>>arr[h];}}↵
void accept_vector(vector<ll>&arr,ll n){for(ll i =0;i<n;i++){cin>>arr[i];}}↵
 ↵
int main() {↵
   ll T;↵
   cin>>T;↵
   for(ll test_case=0;test_case<T;test_case++){↵
       ↵
       ll n, n1;↵
       ll raze_flag=0,breach_flag=0;↵
       cin>>n;↵
       cin>>n1;↵
       ↵
       ostringstream strg;↵
       strg<< n1;↵
       string s = strg.str();↵
       for(ll i =0;i<n;i++){↵
            if(i%2==0){↵
            if((s[i]-'0')%2!=0)↵
            raze_flag++;↵
            }↵
       ↵
            else{↵
            if((s[i]-'0')%2==0)↵
            breach_flag++;↵
           }↵
           if(raze_flag&&breach_flag)↵
           break;↵
       }   ↵
            if(n%2==0)↵
           {↵
               if(breach_flag>0)↵
               cout<<"2"<<endl;↵
               else↵
               cout<<"1"<<endl;↵
           }↵
            else↵
           {↵
               if(raze_flag>0)↵
               cout<<"1"<<endl;↵
               else↵
               cout<<"2"<<endl;↵
           }↵
     ↵
          // s.clear();↵
    ↵
       ↵
       ↵
       ↵
       ↵
   }

 

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English pritesh_808Mafia 2020-09-21 10:49:57 4 Tiny change: 'ssion:93347036]\n\n\n ' -> 'ssion:93342734]\n\n\n '
en2 English pritesh_808Mafia 2020-09-21 10:48:18 1318 (published)
en1 English pritesh_808Mafia 2020-09-21 10:46:50 1443 Initial revision (saved to drafts)