Submission #202717

#TimeUsernameProblemLanguageResultExecution timeMemory
202717ZloyHR전선 연결 (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back
template< typename T,typename V>ostream &operator<< (ostream &out,const pair<T,V> x){ out << "{" << x.fst << " : " << x.snd << "}"; return out;}template< typename T>ostream &operator<< (ostream &out,const set<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T>ostream &operator<< (ostream &out,const multiset<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T,typename V>ostream &operator<< (ostream &out,const map<T,V> x){ for(auto &it : x){ out << "[" << it.fst << "]" << " = " << it.snd << "\n"; } return out;}template< typename T>ostream &operator<< (ostream &out,const vector<T> x){ for(int i = 0;i < x.size() - 1; ++i){ out << x[i] << " "; } out << x.back(); return out;}template< typename T>ostream &operator<< (ostream &out,const vector<vector<T> > x){ for(int i = 0;i < x.size() - 1; ++i){ out << "[" << i << "]" << " = {" << x[i] << "}\n"; } out << "[" << x.size() - 1 << "]" << " = {" << x.back() << "}\n"; return out;}

const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e17;
vector<pll> a;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
    ll n = r.size(),m = b.size();
    ll mxa = 0;
    for(ll i = 0;i < n; ++i){
        ll x;
        x = r[i];
        mxa = max(mxa,x);
        a.pb({x,0});
    }
    ll mnb = INF;
    for(ll i = 0;i < m; ++i){
        ll x;
        x = b[i];
        mnb = min(mnb,x);
        a.pb({x,1});
    }
    sort(all(a));
    vector<ll> pos;
    ll ans = 0;
    int r = -1;
    for(auto &it : pos){
        if(pos.clear() || it.snd == r){
            r = it.snd;
            pos.pb(it.fst);
        }else{
            ans += it.fst - pos.back();
            pos.pop_back();
        }
    }
	return ans;
}

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:41:9: error: declaration of 'int r' shadows a parameter
     int r = -1;
         ^
wiring.cpp:13:13: error: request for member 'second' in 'it', which is of non-class type 'long long int'
 #define snd second
             ^
wiring.cpp:43:30: note: in expansion of macro 'snd'
         if(pos.clear() || it.snd == r){
                              ^~~
wiring.cpp:13:13: error: request for member 'second' in 'it', which is of non-class type 'long long int'
 #define snd second
             ^
wiring.cpp:44:20: note: in expansion of macro 'snd'
             r = it.snd;
                    ^~~
wiring.cpp:12:13: error: request for member 'first' in 'it', which is of non-class type 'long long int'
 #define fst first
             ^
wiring.cpp:45:23: note: in expansion of macro 'fst'
             pos.pb(it.fst);
                       ^~~
wiring.cpp:12:13: error: request for member 'first' in 'it', which is of non-class type 'long long int'
 #define fst first
             ^
wiring.cpp:47:23: note: in expansion of macro 'fst'
             ans += it.fst - pos.back();
                       ^~~