# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
341542 |
2020-12-30T00:21:09 Z |
A_D |
Trener (COCI20_trener) |
C++14 |
|
2000 ms |
5996 KB |
/*
ID: antwand1
TASK: pprime
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define du long double
#define F first
#define S second
#define FOR(a,b) for(int a=1;a<=b;a++)
#define FORl(a,b) for(a=1;a<=b;a++)
#define FOR0(a,b) for(int a=1;a<b;a++)
#define FORl0(a,b) for(a=0;a<b;a++)
#define ii pair<int,int>
using namespace std;
const int MOD=1e9+7;
const int N=55;
const int M=1511;
string a[N][M];
int dp[N][M];
int n,m;
vector<string> vec;
bool ok(string a,string b)
{
string ret;
for(int i=0;i<b.size()-1;i++)ret+=b[i];
if(ret==a)return 1;
ret="";
for(int i=1;i<b.size();i++)ret+=b[i];
return ret==a;
}
int bc(int i,int j)
{
int ret=dp[i][j];
if(ret!=-1)return ret;
if(i==n+1){
for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";cout<<endl;
return ret=1;
}
ret=0;
for(int x=1;x<=m;x++){
if(i==1){
vec.push_back(a[i][x]);
ret+=bc(i+1,x);
vec.pop_back();
}
else{
vec.push_back(a[i][x]);
if(ok(a[i-1][j],a[i][x]))ret+=bc(i+1,x)%MOD;
vec.pop_back();
}
}
return ret%MOD;
}
main()
{
memset(dp,-1,sizeof(dp));
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
cout<<bc(1,1)%MOD;
}
Compilation message
trener.cpp: In function 'bool ok(std::string, std::string)':
trener.cpp:28:18: 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]
28 | for(int i=0;i<b.size()-1;i++)ret+=b[i];
| ~^~~~~~~~~~~
trener.cpp:31:18: 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]
31 | for(int i=1;i<b.size();i++)ret+=b[i];
| ~^~~~~~~~~
trener.cpp: In function 'long long int bc(long long int, long long int)':
trener.cpp:39:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";cout<<endl;
| ~^~~~~~~~~~~
trener.cpp:39:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
39 | for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";cout<<endl;
| ^~~
trener.cpp:39:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
39 | for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";cout<<endl;
| ^~~~
trener.cpp: At global scope:
trener.cpp:57:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
57 | main()
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2080 ms |
5996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |