Submission #936070

# Submission time Handle Problem Language Result Execution time Memory
936070 2024-03-01T05:52:03 Z guagua0407 Naan (JOI19_naan) C++17
Compilation error
0 ms 0 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pll pair<ll,int>

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

bool les(pll a,pll  b){
    return (__int128)a.f*b.s<(__int128)a.s*b.f;
}

void sir(pll &x){
    ll g=__gcd(x.f,x.s);
    x.f/=g;
    x.s/=g;
}

signed main() {_
    int n,l;
    cin>>n>>l;
    vector<vector<int>> v0(n,vector<int>(l));
    vector<vector<int>> v(n,vector<int>(l));
    vector<int> sum(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cin>>v0[i][j];
            sum[i]+=v0[i][j];
            v[i][j]=v0[i][j]*n;
        }
    }
    vector<vector<pll>> cut(n,vector<pll>(n));
    for(int i=0;i<n;i++){
        int pos=0;
        int rem=v[i][0];
        for(int j=0;j<n-1;j++){
            int now=sum[i];
            while(pos<l and rem<=now){
                now-=rem;
                pos++;
                rem=v[i][pos];
            }
            rem-=now;
            cut[i][j]={1ll*v[i][pos]*(pos+1)-rem,v[i][pos]};
            sir(cut[i][j]);
            //cout<<cut[i][j].f<<'/'<<cut[i][j].s<<' ';
        }
        //cout<<'\n';
    }
    vector<bool> used(n);
    vector<int> ans;
    for(int i=0;i<n;i++){
        int mn=-1;
        for(int j=0;j<n;j++){
            if(used[j]) continue;
            if(mn==-1) mn=j;
            else if(les(cut[j][i],cut[mn][i])){
                mn=j;
            }
        }
        ans.push_back(mn);
        used[mn]=true;
    }
    for(int i=0;i<n-1;i++){
        cout<<cut[ans[i]][i].f<<' '<<cut[ans[i]][i].s<<'\n';
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]+1<<' ';
    }
    return 0;
}
//maybe its multiset not set
//yeeorz
//laborz

Compilation message

naan.cpp: In function 'void sir(std::pair<long long int, int>&)':
naan.cpp:25:23: error: no matching function for call to '__gcd(long long int&, int&)'
   25 |     ll g=__gcd(x.f,x.s);
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from naan.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:1219:5: note: candidate: 'template<class _EuclideanRingElement> _EuclideanRingElement std::__gcd(_EuclideanRingElement, _EuclideanRingElement)'
 1219 |     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
      |     ^~~~~
/usr/include/c++/10/bits/stl_algo.h:1219:5: note:   template argument deduction/substitution failed:
naan.cpp:25:23: note:   deduced conflicting types for parameter '_EuclideanRingElement' ('long long int' and 'int')
   25 |     ll g=__gcd(x.f,x.s);
      |                       ^
naan.cpp: In function 'void setIO(std::string)':
naan.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
naan.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~