Submission #893347

# Submission time Handle Problem Language Result Execution time Memory
893347 2023-12-27T02:59:41 Z vjudge1 Road Construction (JOI21_road_construction) C++17
5 / 100
52 ms 9360 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool flag=false;
    if(x>y) x=y;flag|=true;
    return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag=false;
    if (x<y) x=y;flag|=true;
    return flag;
}
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e9+7;
const ll mod=1e9+7;
const ll N=3e3+5;
const ld eps=1e-9;
vll x,y;
ll dis(ll i,ll j){
    return abs(x[i]-x[j])+abs(y[i]-y[j]);
}
void solve(){
	ll i,j;
	ll n,k;
    cin>>n>>k;
    x.resize(n);
    y.resize(n);
    bool flag=true;
    for(i=0;i<n;i++) {
        cin>>x[i]>>y[i];
        if(y[i])flag=false;
    }
    if(n<=1000){
        vll v;
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                v.pb(dis(i,j));
            }
        }
        sort(all(v));
        for(i=0;i<k;i++) cout<<v[i]<<' ';
        cout<<endl;
        return;
    }
    /*
    if(flag){
        vector<pair<ll,ll>> v;
        for(i=0;i<n;i++){
            v.pb({x[i],y[i]});
        }
        sort(all(v));
        bool l[n+5],r[n+5];
        memset(l,false,sizeof(l));
        memset(r,false,sizeof(r));
        set<pair<ll,pair<ll,ll>>> seg;
        for(i=0;i<n;i++){
            seg.ins()
        }
    }*/
}
signed main(){
	start();
    ll t=1;
	//cin>>t;
    while(t--) solve();
    return 0;
}
/*






*/

Compilation message

road_construction.cpp: In function 'bool chmin(_T&, const _T&)':
road_construction.cpp:28:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |     if(x>y) x=y;flag|=true;
      |     ^~
road_construction.cpp:28:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |     if(x>y) x=y;flag|=true;
      |                 ^~~~
road_construction.cpp: In function 'bool chmax(_T&, const _T&)':
road_construction.cpp:34:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   34 |     if (x<y) x=y;flag|=true;
      |     ^~
road_construction.cpp:34:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   34 |     if (x<y) x=y;flag|=true;
      |                  ^~~~
road_construction.cpp: In function 'void solve()':
road_construction.cpp:58:10: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
   58 |     bool flag=true;
      |          ^~~~
road_construction.cpp: In function 'void fre(std::string)':
road_construction.cpp:38:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
road_construction.cpp:38:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 51 ms 7092 KB Output is correct
2 Correct 52 ms 7096 KB Output is correct
3 Correct 35 ms 5216 KB Output is correct
4 Correct 32 ms 5316 KB Output is correct
5 Correct 49 ms 5916 KB Output is correct
6 Correct 17 ms 5068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 7308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 9360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 9360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 7092 KB Output is correct
2 Correct 52 ms 7096 KB Output is correct
3 Correct 35 ms 5216 KB Output is correct
4 Correct 32 ms 5316 KB Output is correct
5 Correct 49 ms 5916 KB Output is correct
6 Correct 17 ms 5068 KB Output is correct
7 Incorrect 17 ms 3932 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 7092 KB Output is correct
2 Correct 52 ms 7096 KB Output is correct
3 Correct 35 ms 5216 KB Output is correct
4 Correct 32 ms 5316 KB Output is correct
5 Correct 49 ms 5916 KB Output is correct
6 Correct 17 ms 5068 KB Output is correct
7 Incorrect 36 ms 7308 KB Output isn't correct
8 Halted 0 ms 0 KB -