| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 95563 | oolimry | Journey (NOI18_journey) | C++14 | 253 ms | 40008 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long l;
typedef pair<l, l> ii;
///stores edges where it comes from, not goes to
vector<ii> adj[10005];
l e;
l memo[10005][405];
///isWaiting 0 - false, 1- true
l dp(l city, l nights){
if(nights < 0){
return 0;
}
if(city == 0 && nights == 0){
return 1;
}
if(memo[city][nights] != -1){
return memo[city][nights];
}
l ways = 0;
for(l i = 0;i < adj[city].size();i++){
l neigh = adj[city][i].first;
l time = adj[city][i].second;
if(neigh < city){
ways += dp(neigh, nights - time);
}
if(ways > 500000001){
return 500000001;
}
}
if(city != e){
ways += dp(city, nights - 1);
}
//printf("%d %d %d\n",city,nights,ways);
if(ways > 500000001){
return 500000001;
}
memo[city][nights] = ways;
return ways;
}
int main()
{
//freopen("i.txt","r",stdin);
l n, m, h;
scanf("%lld %lld %lld",&n,&m,&h);
e = n - 1;
for(int i = 0;i < n - 1;i++){
for(int j = 0;j < h;j++){
l a, b;
scanf("%lld %lld", &a, &b);
adj[a].push_back(ii(i,b));
}
}
memo[0][0] = 1;
for(int i = 0;i < 10003;i++){
for(int j = 0 ;j < 403;j++){
memo[i][j] = -1;
}
}
for(int i = 0;i < n;i++){
for(int j = 0;j < adj[i].size();j++){
//printf("%lld %lld | ",adj[i][j].first,adj[i][j].second);
}
//printf("\n");
}
for(int i = 0;i < m;i++){
printf("%lld ",dp(n-1, i));
//printf("\n\n\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
