Submission #337417

# Submission time Handle Problem Language Result Execution time Memory
337417 2020-12-20T15:59:19 Z ryangohca Naan (JOI19_naan) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;
 
int nums[2000][2000];
pii cuts[2000][2000];
vector<pii> confirmed;
vector<int> order;
bool ordered[2000];
inline int read() {
    int g; cin >> g;
    return g;
}
main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n = read(), l = read();
    for (int i = 0; i < n; i++){
        int need = 0;
        for (int j = 0; j < l; j++){
            cin >> nums[i][j]; nums[i][j] *= n;
            need += nums[i][j];
        }
        need /= n;
        cuts[i][0] = {0, 0};
        int idxwhole = 0, idxpart = 0;
        int curr = 0;
        for (int j = 1; j < n; j++){
            while (need > curr){
                int willtake = nums[i][idxwhole] - idxpart;
                if (curr + willtake <= need){
                    curr += willtake;
                    idxwhole++;
                    idxpart = 0;
                } else {
                    idxpart += need - curr;
                    curr = need;
                }
            }
            cuts[i][j] = pii(idxwhole*nums[i][idxwhole]+idxpart, nums[i][idxwhole]);
            curr = 0;
        }
    }
    for (int i = 1; i < n; i++){
        auto take = pair<pii, int>({INT_MAX, INT_MAX}, -1);
        for (int j = 0; j < n; j++){
            if (ordered[j]) continue;
            pii curr = cuts[j][i];
            if (take.first.first * curr.second - take.first.second * curr.first > 0) continue;
            take = {curr, j};
        }
        ordered[take.second] = true;
        confirmed.push_back({take.first.first, take.second.second});
        order.push_back(take.second);
    }
    for (int i = 0; i < n; i++){
        if (!ordered[i]) order.push_back(i);
    }
    for (auto [a, b] : confirmed){
        int f = __gcd(a, b);
        cout << a/f << ' ' << b/f << '\n';
    }
    for (auto i : order) cout << i + 1 << ' ';
    cout << endl;
}

Compilation message

naan.cpp:15:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      |      ^
naan.cpp: In function 'int main()':
naan.cpp:53:60: error: request for member 'second' in 'take.std::pair<std::pair<long long int, long long int>, long long int>::second', which is of non-class type 'long long int'
   53 |         confirmed.push_back({take.first.first, take.second.second});
      |                                                            ^~~~~~
naan.cpp:53:67: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   53 |         confirmed.push_back({take.first.first, take.second.second});
      |                                                                   ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from naan.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~