답안 #93804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93804 2019-01-11T13:17:07 Z kjain_1810 Shell (info1cup18_shell) C++17
10 / 100
46 ms 8824 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=1e3+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, m, p, arr[N], dp[N][N];
vector<ll>adj[N];

ll solve(ll i, ll j)
{
    if(i==n)
        return j==p;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll ret=0;
    for(ll a=0; a<adj[i].size(); a++)
    {
        ll v=adj[i][a];
        if(v==arr[j+1])
            ret=(ret+solve(v, j+1))%MOD;
        else
            ret=(ret+solve(v, j))%MOD;
    }
    return dp[i][j]=ret;
}

int main() 
{
    inlld3(n, m, p);
    for(ll a=1; a<=p; a++)
        inlld(arr[a]);
    while(m--)
    {
        ll u, v;
        inlld2(u, v);
        adj[u].pb(v);
    }
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(1, 0));
    return 0;
}

Compilation message

shell.cpp: In function 'll solve(ll, ll)':
shell.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll a=0; a<adj[i].size(); a++)
                 ~^~~~~~~~~~~~~~
shell.cpp: In function 'int main()':
shell.cpp:10:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
shell.cpp:43:5: note: in expansion of macro 'inlld3'
     inlld3(n, m, p);
     ^~~~~~
shell.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define inlld(a) scanf("%lld", &a)
                  ~~~~~^~~~~~~~~~~~
shell.cpp:45:9: note: in expansion of macro 'inlld'
         inlld(arr[a]);
         ^~~~~
shell.cpp:8:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define inlld2(a, b) scanf("%lld%lld", &a, &b)
                      ~~~~~^~~~~~~~~~~~~~~~~~~~
shell.cpp:49:9: note: in expansion of macro 'inlld2'
         inlld2(u, v);
         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8440 KB Output is correct
2 Correct 7 ms 8316 KB Output is correct
3 Correct 7 ms 8184 KB Output is correct
4 Correct 7 ms 8312 KB Output is correct
5 Correct 7 ms 8184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8440 KB Output is correct
2 Correct 7 ms 8316 KB Output is correct
3 Correct 7 ms 8184 KB Output is correct
4 Correct 7 ms 8312 KB Output is correct
5 Correct 7 ms 8184 KB Output is correct
6 Correct 7 ms 8312 KB Output is correct
7 Correct 46 ms 8824 KB Output is correct
8 Incorrect 10 ms 8568 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 8312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8440 KB Output is correct
2 Correct 7 ms 8316 KB Output is correct
3 Correct 7 ms 8184 KB Output is correct
4 Correct 7 ms 8312 KB Output is correct
5 Correct 7 ms 8184 KB Output is correct
6 Correct 7 ms 8312 KB Output is correct
7 Correct 46 ms 8824 KB Output is correct
8 Incorrect 10 ms 8568 KB Output isn't correct
9 Halted 0 ms 0 KB -