Submission #341538

# Submission time Handle Problem Language Result Execution time Memory
341538 2020-12-29T23:55:38 Z A_D Trener (COCI20_trener) C++14
22 / 110
200 ms 4076 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;
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){
  //      cout<<i<<" "<<j<<endl;
        return ret=1;
    }
    ret=0;
    for(int x=1;x<=m;x++){
        if(i==1)ret+=bc(i+1,x);
        else{
            if(ok(a[i-1][j],a[i][x]))ret+=bc(i+1,x)%MOD;
        }
    }
    return ret;
}
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);
}





Compilation message

trener.cpp: In function 'bool ok(std::string, std::string)':
trener.cpp:27: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]
   27 |     for(int i=0;i<b.size()-1;i++)ret+=b[i];
      |                 ~^~~~~~~~~~~
trener.cpp:30: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]
   30 |     for(int i=1;i<b.size();i++)ret+=b[i];
      |                 ~^~~~~~~~~
trener.cpp: At global scope:
trener.cpp:50:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3564 KB Output is correct
3 Correct 3 ms 3564 KB Output is correct
4 Correct 3 ms 3564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 3948 KB Output is correct
2 Correct 200 ms 3948 KB Output is correct
3 Correct 199 ms 4076 KB Output is correct
4 Incorrect 135 ms 3948 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3564 KB Output is correct
3 Correct 3 ms 3564 KB Output is correct
4 Correct 3 ms 3564 KB Output is correct
5 Correct 193 ms 3948 KB Output is correct
6 Correct 200 ms 3948 KB Output is correct
7 Correct 199 ms 4076 KB Output is correct
8 Incorrect 135 ms 3948 KB Output isn't correct
9 Halted 0 ms 0 KB -