#include <bits/stdc++.h>
using namespace std;
#define Baetov_Arlen void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
#define endl '\n'
#define sz(x) x.size()
const int INF=1e18;
int fact(int h){
if(h==0){
return 1;
}
else{
return (h * fact(h-1));
}
}
int gcd(int a,int b){
if(0==b) return a;
return gcd(b,a%b);
}
double pw(double a,int b){
if(0==b)return 1;
if(b%2==1)
return a*pw(a,b-1);
else
return pw(a*a, b/2);
}
int fib(int a){
if(a<=1){
return a;
}
else{
return fib(a-1)+fib(a-2);
}
}
//printf("%.2f", pi);
int a,b,d,e,f,g,h,l,r,o,n=0,m,i=0,j=0,k,x,y,cnt=0,sum=0,res=0,p=0;
Baetov_Arlen{
cin>>a>>b;
vector<pair<string,int>>v(a);
for(n=0;n<a;n++){
cin>>v[n].fr;
v[n].sc=0;
}
vector<int>vv(b);
vector<pair<string,string>>s(b);
for(n=0;n<b;n++){
cin>>s[n].fr>>s[n].sc;
vv[n]=0;
}
for(i=0;i<a;i++){
res=0;
n=0;
string ss,cc,zz;
ss=v[i].fr;
for(j=0;j<b;j++){
cc=s[j].fr;
zz=s[j].sc;
if(cc[0]==ss[0]){
x=0;
y=0;
for(o=0;o<sz(cc);o++){
if(cc[o]==ss[o]){
x++;
}
}
if(x==sz(cc)){
int u=1;
for(o=sz(zz)-1;o>=0;o--){
if(zz[o]==ss[sz(ss)-u]){
y++;
}
u++;
}
if(y==sz(zz)){
vv[j]++;
}
}
}
}
}
for(n=0;n<b;n++){
cout<<vv[n]<<endl;
}
}
main(){
ios;
int T=1;
// cin>>T;
while(T--){
solve();
}
}
Compilation message
selling_rna.cpp: In function 'void solve()':
selling_rna.cpp:69:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(o=0;o<sz(cc);o++){
| ^
selling_rna.cpp:74:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | if(x==sz(cc)){
| ^
selling_rna.cpp:82:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | if(y==sz(zz)){
| ^
selling_rna.cpp: At global scope:
selling_rna.cpp:96:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
96 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1578 ms |
5132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1572 ms |
5724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Execution timed out |
1578 ms |
5132 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |