Submission #14218

# Submission time Handle Problem Language Result Execution time Memory
14218 2015-05-05T08:30:00 Z gs14004 선다형 시험 (TOKI14_multiple) C++14
24 / 100
73 ms 34752 KB
#include <cstdio>
#include <cstring>
const int mod = 1e9 + 7;

int n, p, q;
char sa[2005], sb[2005];
char tab[2005][6];

int dp[205][205][205];

int f(int pos, int p, int q){
    if(p < 0 || q < 0) return 0;
    if(pos == n) return p == 0 && q == 0;
    if(~dp[pos][p][q]) return dp[pos][p][q];
    int ret = 0;
    for (int i=0; i<5; i++) {
        if(tab[pos][i] != '.'){
            ret += f(pos+1,p - (sa[pos] == tab[pos][i]),q - (sb[pos] == tab[pos][i]));
            ret %= mod;
        }
    }
    return dp[pos][p][q] = ret;
}

void what_the_fuck(){
    char str[10];
    memset(dp,-1,sizeof(dp));
    scanf("%d %d %d",&n,&p,&q);
    for (int i=0; i<n; i++) {
        scanf("%s",str);
        sa[i] = str[0];
    }
    for (int i=0; i<n; i++) {
        scanf("%s",str);
        sb[i] = str[0];
    }
    for (int i=0; i<n; i++) {
        scanf("%s",tab[i]);
    }
    printf("%d",f(0,p,q));
}

int main(){
    what_the_fuck();
    puts("");
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 34752 KB Output is correct
2 Correct 4 ms 34752 KB Output is correct
3 Correct 0 ms 34752 KB Output is correct
4 Correct 4 ms 34752 KB Output is correct
5 Correct 4 ms 34752 KB Output is correct
6 Correct 4 ms 34752 KB Output is correct
7 Correct 0 ms 34752 KB Output is correct
8 Correct 6 ms 34752 KB Output is correct
9 Correct 30 ms 34752 KB Output is correct
10 Correct 73 ms 34752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 34752 KB Output is correct
2 Correct 4 ms 34752 KB Output is correct
3 Runtime error 0 ms 34748 KB SIGSEGV Segmentation fault
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 34748 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -