# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
785043 |
2023-07-17T01:22:12 Z |
tolbi |
Toll (BOI17_toll) |
C++17 |
|
3000 ms |
6504 KB |
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& is, pair<X,Y> &pr){return is>>pr.first>>pr.second;}
#ifdef tolbi
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr){return os<<"{ "<<pr.first<<", "<<pr.second<<" }";}
#else
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr){return os<<pr.first<<" "<<pr.second;}
#endif
ostream& operator<<(ostream& os, bool bl){return os<<(int32_t)bl;}
template<typename X> istream& operator>>(istream& is, vector<X> &arr){for (auto &it : arr) is>>it; return is;}
template<typename X, size_t Y> istream& operator>>(istream& is, array<X,Y> &arr){for (auto &it : arr) is>>it; return is;}
template<typename X> ostream& operator<<(ostream& os, vector<X> &arr){for (auto &it : arr) os<<" "<<it;os<<endl;return os;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> &arr){for (auto &it : arr) os<<" "<<it;os<<endl;return os;}
#define int long long
#define endl '\n'
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for(auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define tol(bi) (1LL<<((int)(bi)))
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = LONG_LONG_MAX;
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
ios;
int T = 1;
if (!T) cin>>T;
int tno = 0;
while (T-(tno++)){
deci(k);deci(n);deci(m);deci(q);
vector<vector<vector<pair<int,int>>>> arr((n+k-1)/k,vector<vector<pair<int,int>>>(k));
for (int i = 0; i < m; ++i)
{
deci(a);deci(b);deci(x);
arr[a/k][a%k].push_back({b%k,x});
}
while (q--){
deci(a);deci(b);
vector<int> crr(k,INF);
crr[a%k]=0;
if (a==b) {
cout<<0<<endl;
continue;
}
if (b/k<=a/k){
cout<<-1<<endl;
continue;
}
for (int i = a/k; i < b/k; i++){
vector<int> newcrr(k,INF);
for (int j = 0; j < k; j++){
if (crr[j]==INF) continue;
for (int z = 0; z < arr[i][j].size(); z++){
newcrr[arr[i][j][z].first]=min(newcrr[arr[i][j][z].first],crr[j]+arr[i][j][z].second);
}
}
swap(crr,newcrr);
}
if (crr[b%k]==INF){
cout<<-1<<endl;
}
else {
cout<<crr[b%k]<<endl;
}
}
}
}
Compilation message
toll.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
toll.cpp: In function 'int32_t main()':
toll.cpp:67:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for (int z = 0; z < arr[i][j].size(); z++){
| ~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
4956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3063 ms |
5268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
41 ms |
4744 KB |
Output is correct |
11 |
Correct |
54 ms |
5064 KB |
Output is correct |
12 |
Correct |
67 ms |
6212 KB |
Output is correct |
13 |
Correct |
66 ms |
6376 KB |
Output is correct |
14 |
Correct |
67 ms |
5208 KB |
Output is correct |
15 |
Correct |
34 ms |
3276 KB |
Output is correct |
16 |
Correct |
32 ms |
3284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
41 ms |
4744 KB |
Output is correct |
11 |
Correct |
54 ms |
5064 KB |
Output is correct |
12 |
Correct |
67 ms |
6212 KB |
Output is correct |
13 |
Correct |
66 ms |
6376 KB |
Output is correct |
14 |
Correct |
67 ms |
5208 KB |
Output is correct |
15 |
Correct |
34 ms |
3276 KB |
Output is correct |
16 |
Correct |
32 ms |
3284 KB |
Output is correct |
17 |
Correct |
852 ms |
5256 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
324 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
16 ms |
432 KB |
Output is correct |
24 |
Correct |
13 ms |
468 KB |
Output is correct |
25 |
Correct |
11 ms |
444 KB |
Output is correct |
26 |
Correct |
11 ms |
468 KB |
Output is correct |
27 |
Correct |
673 ms |
4692 KB |
Output is correct |
28 |
Correct |
740 ms |
6192 KB |
Output is correct |
29 |
Correct |
720 ms |
6504 KB |
Output is correct |
30 |
Correct |
608 ms |
5300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
4956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |