Submission #893340

# Submission time Handle Problem Language Result Execution time Memory
893340 2023-12-27T02:42:54 Z vjudge1 Road Construction (JOI21_road_construction) C++17
5 / 100
1721 ms 2097152 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

bool YES(bool f){ if(f) cout << "Yes\n" ; else cout << "No\n" ; return f ; }
void YES(){YES(1);}
void NO(){YES(0);}
void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define ld long double
#define pii pair <int , int>
#define all(x) x.begin() , x.end()
#define ff first
#define ss second
#define endl '\n'

const int N = 2e6 + 5 ;
const int inf = 1e18 ;
const int mod = 998244353 ;
const double eps = 1e-8 ;

int binpow( int a , int b ){
  if ( b == 0 ) return 1 ;
  int x = binpow ( a , b/2 ) ;
  if ( !(b%2) ) return (x*x) ;
  return (x*x*a) ;
}
template <class T>
bool chmax( T& x , const T& y ){
  bool f = 0 ;
  if ( x < y ) x = y , f = 1 ;
  return f ;
}
template <class T>
bool chmin( T &x , const T &y ){
  bool f = 0 ;
  if ( x > y ) x = y , f = 1 ;
  return f ;
}

//code

int n , k ;
vector <int> ans ;
pii a[N] ;

int dist ( int x , int y , int x1 , int y1 ){
	return abs(x-x1)+abs(y-y1) ;
}

void solve(){
	
	cin >> n >> k ;
	for ( int i = 0 ; i < n ; i ++ ) cin >> a[i].ss >> a[i].ff ;
	sort ( a , a + n ) ;
	/*if ( a[0].ff == a[n-1].ff ){
		for ( int i = 1 ; i < n ; i ++ ){
			
		}
	}*/
	for ( int i = 0 ; i < n ; i ++ ){
		for ( int j = i+1 ; j < n ; j ++ ) ans.push_back(dist(a[i].ff,a[i].ss,a[j].ff,a[j].ss)) ;
	}
	sort ( ans.begin() , ans.end() ) ;
	for ( int i = 0 ; i < k ; i ++ ) cout << ans[i] << '\n' ;
	 	
}

signed main(){
    ios ;
	int t = 1 ;
	//cin >> t ;
	while ( t -- ) solve() ;
}

Compilation message

road_construction.cpp: In function 'void fopn(std::string)':
road_construction.cpp:10:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
road_construction.cpp:10:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6932 KB Output is correct
2 Correct 52 ms 7100 KB Output is correct
3 Correct 33 ms 5060 KB Output is correct
4 Correct 33 ms 5068 KB Output is correct
5 Correct 51 ms 6352 KB Output is correct
6 Correct 15 ms 5584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1721 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1142 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1142 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6932 KB Output is correct
2 Correct 52 ms 7100 KB Output is correct
3 Correct 33 ms 5060 KB Output is correct
4 Correct 33 ms 5068 KB Output is correct
5 Correct 51 ms 6352 KB Output is correct
6 Correct 15 ms 5584 KB Output is correct
7 Runtime error 1004 ms 2097152 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6932 KB Output is correct
2 Correct 52 ms 7100 KB Output is correct
3 Correct 33 ms 5060 KB Output is correct
4 Correct 33 ms 5068 KB Output is correct
5 Correct 51 ms 6352 KB Output is correct
6 Correct 15 ms 5584 KB Output is correct
7 Runtime error 1721 ms 2097152 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -