답안 #1039607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039607 2024-07-31T05:25:58 Z 김은성(#10990) Petrol stations (CEOI24_stations) C++17
18 / 100
3500 ms 10152 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int, int> > graph[70009];
bool ch[70009];
ll ans[70009];
int cap;
int dfs(int v, int fuel){
    ch[v] = 1;
    int sz = 1, i;
    for(i=0; i<graph[v].size(); i++){
        int u = graph[v][i].first;
        if(ch[u])
            continue;
        if(graph[v][i].second > fuel){
            int temp = dfs(u, cap - graph[v][i].second);
            sz += temp;
            ans[v] += temp;
        }
        else
            sz += dfs(u, fuel - graph[v][i].second);
    }
    return sz;
}
int main(){
    int n, i, a, b, c;
    scanf("%d %d", &n, &cap);
    for(i=1; i<n; i++){
        scanf("%d %d %d",&a, &b, &c);
        graph[a].push_back(make_pair(b, c));
        graph[b].push_back(make_pair(a, c));
    }
    for(i=0; i<n; i++){
        memset(ch, 0, sizeof(ch));
        dfs(i, cap);
    }
    for(i=0; i<n; i++)
        printf("%lld\n", ans[i]);
    return 0;
}

Compilation message

Main.cpp: In function 'int dfs(int, int)':
Main.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(i=0; i<graph[v].size(); i++){
      |              ~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d %d", &n, &cap);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d %d %d",&a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 7 ms 2140 KB Output is correct
4 Correct 12 ms 2200 KB Output is correct
5 Correct 9 ms 2140 KB Output is correct
6 Correct 17 ms 2260 KB Output is correct
7 Correct 14 ms 2140 KB Output is correct
8 Correct 1 ms 2088 KB Output is correct
9 Correct 9 ms 2136 KB Output is correct
10 Correct 9 ms 2140 KB Output is correct
11 Correct 10 ms 2216 KB Output is correct
12 Correct 9 ms 2212 KB Output is correct
13 Correct 10 ms 2208 KB Output is correct
14 Correct 7 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2136 KB Output is correct
2 Execution timed out 3575 ms 10152 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 1 ms 2136 KB Output is correct
4 Execution timed out 3575 ms 10152 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Execution timed out 3536 ms 5660 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Execution timed out 3536 ms 5660 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 7 ms 2140 KB Output is correct
4 Correct 12 ms 2200 KB Output is correct
5 Correct 9 ms 2140 KB Output is correct
6 Correct 17 ms 2260 KB Output is correct
7 Correct 14 ms 2140 KB Output is correct
8 Correct 1 ms 2088 KB Output is correct
9 Correct 9 ms 2136 KB Output is correct
10 Correct 9 ms 2140 KB Output is correct
11 Correct 10 ms 2216 KB Output is correct
12 Correct 9 ms 2212 KB Output is correct
13 Correct 10 ms 2208 KB Output is correct
14 Correct 7 ms 2140 KB Output is correct
15 Correct 1 ms 2136 KB Output is correct
16 Execution timed out 3575 ms 10152 KB Time limit exceeded
17 Halted 0 ms 0 KB -