답안 #496799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496799 2021-12-22T04:38:33 Z kingline Coin Collecting (JOI19_ho_t4) C++17
0 / 100
0 ms 332 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
#define int long long
#define pii pair < ll, ll >

using namespace std;

const int N = 4e5 + 5;
const int lg = 21;

int n, x[N], y[N], used[N];

main() {
    //file("pieaters");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vector < pair < int, pii > > v;
    for(int i = 1; i <= n * 2; i++) {
        cin >> x[i] >> y[i];
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= 2; k++) {
                v.pb({abs(x[i] - j) + abs(y[i] - k), {i, (j - 1) * 2 + k + n * 2}});
            }
        }
    }
    sort(all(v));
    int ans = 0;
    for(int i = 0; i < v.size(); i++) {
        int a = v[i].second.first, b = v[i].second.second, len = v[i].first;
        //cout << len << " " << a << " " << b << endl;
        if(!used[a] && !used[b]) {
            used[a] = used[b] = 1;
            ans += len;
        }
    }
    cout << ans;
}





Compilation message

joi2019_ho_t4.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main() {
      | ^~~~
joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:39:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Incorrect 0 ms 332 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Incorrect 0 ms 332 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Incorrect 0 ms 332 KB Output isn't correct
7 Halted 0 ms 0 KB -