Submission #162985

# Submission time Handle Problem Language Result Execution time Memory
162985 2019-11-10T15:58:36 Z Minnakhmetov Toll (BOI17_toll) C++14
7 / 100
3000 ms 4600 KB
#include <bits/stdc++.h>
    
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
 
using namespace std;

struct E {
	int a, b, w;
};

const int N = 1e5 + 5, INF = 1e9;
E e[N];
int d[N];
 
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n, m, k, o;
    cin >> k >> n >> m >> o;

    for (int i = 0; i < m; i++) {
    	cin >> e[i].a >> e[i].b >> e[i].w;
    }

    sort(e, e + m, [](E x, E y) {
    	return x.a < y.a;
    });

    for (int i = 0; i < o; i++) {
    	int x, y;
    	cin >> x >> y;

    	fill(d, d + n, INF);

    	d[x] = 0;

    	for (int j = 0; j < m; j++) {
    		d[e[j].b] = min(d[e[j].b], d[e[j].a] + e[j].w);
    	}

    	if (d[y] == INF)
    		cout << "-1\n";
    	else
    		cout << d[y] << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2118 ms 2312 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 2069 ms 2296 KB Output is correct
9 Correct 1955 ms 2040 KB Output is correct
10 Correct 249 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3035 ms 3424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 43 ms 1912 KB Output is correct
11 Correct 77 ms 3300 KB Output is correct
12 Runtime error 35 ms 4600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 43 ms 1912 KB Output is correct
11 Correct 77 ms 3300 KB Output is correct
12 Runtime error 35 ms 4600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2118 ms 2312 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 2069 ms 2296 KB Output is correct
9 Correct 1955 ms 2040 KB Output is correct
10 Correct 249 ms 760 KB Output is correct
11 Execution timed out 3035 ms 3424 KB Time limit exceeded
12 Halted 0 ms 0 KB -