#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int O = 3e3 + 3;
vector<pair<int , int> > g[N] , query;
int pre[N] , pr[N] , k , n , m , o;
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
memset(pr , -1 , sizeof(pr));
cin >> k >> n >> m >> o;
for(int i = 0 ; i < m ; i++){
int u , v , w;
cin >> u >> v >> w;
g[u].push_back({v , w});
}
for(int i = 0 ; i < o ; i++){
int a , b;
cin >> a >> b;
query.push_back({a , b});
}
if(k == 1){
int bef = 0;
for(int i = 0 ; i < n ; i++){
if(i == bef)
pre[i] = 0;
else
pre[i] = pre[i - 1] + g[i - 1][0].second;
pr[i] = bef;
if(!g[i].size()){
while(!g[i].size())i++;
bef = i;
i--;
}
}
for(auto i : query){
if(pr[i.first] == -1 || pr[i.second] == -1 || pr[i.first] != pr[i.second] || i.second < i.first)
cout << -1 << '\n';
else
cout << pre[i.second] - pre[i.first] << '\n';
}
return 0;
}
cout << "jalebe" << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
5068 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
5 |
Correct |
3 ms |
3028 KB |
Output is correct |
6 |
Correct |
3 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3028 KB |
Output is correct |
8 |
Correct |
25 ms |
5044 KB |
Output is correct |
9 |
Correct |
19 ms |
4948 KB |
Output is correct |
10 |
Correct |
5 ms |
3284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
4720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3028 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3028 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
5068 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
5 |
Correct |
3 ms |
3028 KB |
Output is correct |
6 |
Correct |
3 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3028 KB |
Output is correct |
8 |
Correct |
25 ms |
5044 KB |
Output is correct |
9 |
Correct |
19 ms |
4948 KB |
Output is correct |
10 |
Correct |
5 ms |
3284 KB |
Output is correct |
11 |
Incorrect |
33 ms |
4720 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |