https://www.codechef.com/viewsolution/30894092
I used recursion to count the required substrings
Can someone have a look at my code and tell what is wrong
https://www.codechef.com/viewsolution/30894092
I used recursion to count the required substrings
Can someone have a look at my code and tell what is wrong
looks like you have to change class name to Main().
i am not sure but most likely this would be the error.
On my machine, your solution fails on this testcase with the following error:
Exception in thread "main" java.lang.StackOverflowError
at java.base/java.lang.StringLatin1.newString(StringLatin1.java:715)
at java.base/java.lang.String.substring(String.java:1846)
at Ideone.CountSubstrings(lynton_1765-CSUB.java:24)
at Ideone.CountSubstrings(lynton_1765-CSUB.java:24)
... the last couple of lines repeated over and over ...
So is there a problem in my approach or it is something else
Can you please tell how do you test on which tc it gives WA/TLE?
Probably something like this
#include <iostream>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
bool correct=1;
while(correct){
//Generate tc
FILE *input1=freopen("input1.txt","w",stdout);
//Put Tc in file 1
fclose(input1);
FILE *input2=freopen("input2.txt","w",stdout);
// Put Tc in file 2
fclose(input2);
system("C:\\Users\\Public\\correct.exe");
system("C:\\Users\\Public\\mine.exe");
FILE *correct=freopen("output1.txt","r",stdin);
//input correct answer
fclose(correct);
FILE *mine=freopen("output2.txt","r",stdin);
//input my answer
fclose(mine);
if(//check answer){
FILE *wrong=freopen("wrong.txt","w",stdout);
//Write wrong answer here
fclose(wrong);
break;
}
}
}
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
using namespace std;
ll solve(){
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
FILE *input=freopen("input1.txt","r",stdin);
FILE *output=freopen("output1.txt","w",stdout);
solve();
cout<<endl;
fclose(input);
fclose(output);
}
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
ll solve(){
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
FILE *input=freopen("input2.txt","r",stdin);
FILE *output=freopen("output2.txt","w",stdout);
solve();
cout<<endl;
fclose(input);
fclose(output);
}