Submission #417727

# Submission time Handle Problem Language Result Execution time Memory
417727 2021-06-04T08:09:39 Z 조영욱(#7641) Long puzzle (innopolis2021_final_D) C++17
20 / 100
2 ms 972 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> st;
vector<int> en;
vector<int> v;
const int mod=1e9+7;
int val[301];
long long dp[301][301];

int main(void) {
    long long ret=0;
    int n,l;
    scanf("%d %d",&n,&l);
    v.push_back(0);
    for(int i=0;i<n;i++) {
        char str1[7];
        char str2[7];
        int x;
        scanf("%d %s %s",&x,str1,str2);
        if (strcmp(str1,"in")==0) {
            if (strcmp(str2,"out")==0)
                v.push_back(x);
            else
                en.push_back(x);
        }
        else {
            if (strcmp(str2,"out")==0)
                st.push_back(x);
            else
                ret+=(x==l);
        }
    }
    for(int i=0;i<st.size();i++) {
        for(int j=0;j<en.size();j++) {
            if (st[i]+en[j]<=l) {
                val[st[i]+en[j]]++;
            }
        }
    }
    dp[0][0]=1;
    for(int i=1;i<v.size();i++) {
        for(int j=0;j<=l;j++) {
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
        }
        for(int j=0;j<=l-v[i];j++) {
            dp[i][j+v[i]]+=dp[i-1][j];
            dp[i][j+v[i]]%=mod;
        }
    }
    for(int i=0;i<=l;i++) {
        ret+=val[l-i]*dp[v.size()-1][i];
        ret%=mod;
    }
    printf("%lld",ret);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0;i<st.size();i++) {
      |                 ~^~~~~~~~~~
Main.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j=0;j<en.size();j++) {
      |                     ~^~~~~~~~~~
Main.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=1;i<v.size();i++) {
      |                 ~^~~~~~~~~
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d %d",&n,&l);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d %s %s",&x,str1,str2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 2 ms 876 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -