답안 #629973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629973 2022-08-15T13:02:02 Z urosk Toll (BOI17_toll) C++14
컴파일 오류
0 ms 0 KB
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
using namespace __gnu_pbds;
/*
ll add(ll x,ll y){
    x+=y;
    if(x<0){
        x%=mod;
        x+=mod;
    }else{
        if(x>=mod) x%=mod;
    }
    return x;
}
ll mul(ll a,ll b){
	ll ans = (a*b)%mod;
	if(ans<0) ans+=mod;
	return ans;
}
*/
typedef tree<int,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l,ll r){
    return uniform_int_distribution<ll>(l,r)(rng);
}
#define maxn 50005
#define lg 20
ll n,k,m,q;
struct mat{
    ll a[5][5];
    mat(){
        for(ll i = 0;i<5;i++) for(ll j = 0;j<5;j++) a[i][j] = llinf;
    }
    mat operator + (mat b){
        mat c;
        for(ll i = 0;i<5;i++){
            for(ll j = 0;j<5;j++){
                for(ll k = 0;k<5;k++){
                    c.a[i][j] = min(c.a[i][j],a[i][k] + b.a[k][j]);
                }
            }
        }
        return c;
    }
};
mat dp[maxn][lg];

int main(){
	daj_mi_malo_vremena
    cin >> k >> n >> m >> q;
    for(ll i = 1;i<=m;i++){
        ll x,y,w; cin >> x >> y >> w;
        dp[x/k][0].a[x%k][y%k] = w;
    }
    for(ll j = 1;j<lg;j++){
        for(ll i = 0;i<n;i++){
            if(i+(1<<j)+1>n) break;
            dp[i][j] = dp[i][j-1] + dp[i+(1<<(j-1))][j-1];
        }
    }
    while(q--){
        ll x,y; cin >> x >> y;
        ll xd = x/k,yd = y/k;
        if(xd==yd){cout<<-1<<endl; continue;}
        mat ans;
        for(ll i = 0;i<5;i++) ans[i][i] = 0;
        for(ll j = lg-1;j>=0;j--){
            if(xd+(1<<j)<=yd){
                ans = ans + dp[xd][j];
                xd+=(1<<j)+1;
            }
        }
        ll val = ans.a[x%k][y%k];
        if(val==llinf) val = -1;
        cout<<val<<endl;
    }
	return 0;
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:86:34: error: no match for 'operator[]' (operand types are 'mat' and 'long long int')
   86 |         for(ll i = 0;i<5;i++) ans[i][i] = 0;
      |                                  ^