Submission #692863

# Submission time Handle Problem Language Result Execution time Memory
692863 2023-02-02T06:39:14 Z tolbi Chessboard (IZhO18_chessboard) C++17
0 / 100
2000 ms 194980 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#ifdef LOCAL
	#include "23.h"
#endif
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#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 det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
	ios;
	int t=1;
	int tno = 0;
	if (!t) cin>>t;
	while (t-(tno++)){
		deci(n);deci(m);
		vector<vector<pair<int,int>>> arr(n);
		for (int i = 0; i < m; i++){
			deci(u);deci(v);deci(w);
			arr[u-1].push_back({v-1,w});
			arr[v-1].push_back({u-1,w});
		}
		deci(k);
		vector<int> zar(n,MOD);
		priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
		for (int i = 0; i < k; i++){
			deci(x);
			pq.push({0,x-1});
		}
		while (pq.size()){
			int nod = pq.top().second;
			int w = pq.top().first;
			pq.pop();
			if (zar[nod]<=w) continue;
			zar[nod]=w;
			for (int i = 0; i < arr[nod].size(); i++){
				if (zar[arr[nod][i].first]<=w+arr[nod][i].second) continue;
				pq.push({w+arr[nod][i].second,arr[nod][i].first});
			}
		}
		deci(q);
		while (q--){
			deci(u);deci(v);
			int l = 0, r = MOD;
			priority_queue<int> ppq;
			while (l<r){
				int mid = l+(r-l+1)/2;
				if (zar[u-1]<mid) {
					r=mid-1;
					continue;
				}
				ppq.push(u-1);
				vector<bool> var(n);
				while (ppq.size()){
					int node = ppq.top();
					ppq.pop();
					if (var[node]) continue;
					var[node]=true;
					for (int i = 0; i < arr[node].size(); i++){
						if (zar[arr[node][i].first]<mid) continue;
						if (var[arr[node][i].first]) continue;
						ppq.push(arr[node][i].first);
					}
				}
				if (var[v-1]){
					l=mid;
				}
				else r = mid-1;
			}
			cout<<l<<endl;
		}
	}
}

Compilation message

chessboard.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
chessboard.cpp: In function 'int32_t main()':
chessboard.cpp:59:22: 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]
   59 |    for (int i = 0; i < arr[nod].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~
chessboard.cpp:82: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]
   82 |      for (int i = 0; i < arr[node].size(); i++){
      |                      ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 303 ms 194980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 7440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 7440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 303 ms 194980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -