Submission #1157697

#TimeUsernameProblemLanguageResultExecution timeMemory
1157697Kaztaev_AlisherRoad Construction (JOI21_road_construction)C++20
0 / 100
75 ms7080 KiB
#include <bits/stdc++.h>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;

const ll N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7;

int x[N] , y[N];
int n , k;
int get(int i , int j){
	return abs(x[i]-x[j]) + abs(y[i]-y[j]);
}
void slow(){
	vector<pair<int,int>> v;
	for(int i = 1; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			v.push_back({i,j});
		}
	}
	sort(all(v),[&](pair<int,int> i , pair<int,int> j){
		return (get(i.F , i.S) < get(j.F , j.S));
		
	});
	for(int i = 0; i < k; i++){
		cout << get(v[i].F,v[i].S) << "\n";
	}
}
void k_one(){
	
}
void only_x(){
	
}
void solve(){
	cin >> n >> k;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> y[i];
		if(y[i] == 0){
			cnt++;
		}
	}
	if(cnt == n){
		only_x();
	} else if(k == 1){
		k_one();
	} else {
		slow();
	}
}
/*

*/
signed main(){
	ios;
	solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...