답안 #341549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341549 2020-12-30T00:50:51 Z A_D Trener (COCI20_trener) C++14
55 / 110
2000 ms 18796 KB
/*
ID: antwand1
TASK: pprime
LANG: C++
*/
#include <bits/stdc++.h>
#define ll 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];
ll dp[N][M];
string sub[N][M][2];
int n,m;
string get(string&s,int l,int r)
{
    string ret;
    for(int i=l;i<=r;i++)ret+=s[i];return ret;
}
ll bc(int i,int j)
{
    ll&ret=dp[i][j];
    if(ret!=-1)return ret;
    if(i==n+1){
        return ret=1;
    }
    ret=0;
    for(int x=1;x<=m;x++){
        if(i==1){
            ret+=bc(i+1,x);
        }
        else{
            if(a[i-1][j]==sub[i][x][0]||a[i-1][j]==sub[i][x][1])ret+=bc(i+1,x)%MOD;
            ret%=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];
            for(int k=0;k<2;k++){
                sub[i][j][k]=get(a[i][j],k,k+i-2);
            }
        }
    }
    cout<<bc(1,1)%MOD;
}

Compilation message

trener.cpp: In function 'std::string get(std::string&, int, int)':
trener.cpp:27:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   27 |     for(int i=l;i<=r;i++)ret+=s[i];return ret;
      |     ^~~
trener.cpp:27:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   27 |     for(int i=l;i<=r;i++)ret+=s[i];return ret;
      |                                    ^~~~~~
trener.cpp: At global scope:
trener.cpp:48:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8812 KB Output is correct
2 Correct 6 ms 8812 KB Output is correct
3 Correct 6 ms 8812 KB Output is correct
4 Correct 6 ms 8812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 9580 KB Output is correct
2 Correct 26 ms 9452 KB Output is correct
3 Correct 23 ms 9452 KB Output is correct
4 Correct 18 ms 9452 KB Output is correct
5 Correct 27 ms 9452 KB Output is correct
6 Correct 26 ms 9452 KB Output is correct
7 Correct 18 ms 9472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8812 KB Output is correct
2 Correct 6 ms 8812 KB Output is correct
3 Correct 6 ms 8812 KB Output is correct
4 Correct 6 ms 8812 KB Output is correct
5 Correct 22 ms 9580 KB Output is correct
6 Correct 26 ms 9452 KB Output is correct
7 Correct 23 ms 9452 KB Output is correct
8 Correct 18 ms 9452 KB Output is correct
9 Correct 27 ms 9452 KB Output is correct
10 Correct 26 ms 9452 KB Output is correct
11 Correct 18 ms 9472 KB Output is correct
12 Execution timed out 2073 ms 18796 KB Time limit exceeded
13 Halted 0 ms 0 KB -