QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#410392#676. Travelling MerchantYahia_Emara#0 119ms12612kbC++203.8kb2024-05-13 22:56:022024-05-13 22:56:03

Judging History

你现在查看的是最新测评结果

  • [2024-05-13 22:56:03]
  • 评测
  • 测评结果:0
  • 用时:119ms
  • 内存:12612kb
  • [2024-05-13 22:56:02]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define LOOP(n) for(int rp=0;rp<(n);rp++)
#define sz(x) int(x.size())
#define bk(x) x.back()
#define dbg(x) cout << (#x) << " : " << x << endl
#define sdbg(x) cout << (#x) << " : " << x << "\n"
#define dbeg(x) cout << (#x) << " : " << x << ", "
#define sq(x) ((x)*(x))
#define lsb(x) ((x)&(-(x)))
#define sqm(x) mul((x),(x))
#define isnp(x) ((x)&((x)-1))
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
#define fsh cout.flush()
using namespace std;
using namespace __gnu_pbds;
#define OS tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ofk order_of_key
//#pragma GCC optimize("trapv")
#pragma GCC optimize("Ofast","unroll-loops","O3")
#pragma GCC target("avx2")
mt19937_64 rng(time(0));
int rnd(int l,int r){
    return uniform_int_distribution<int>(l,r)(rng);
}
typedef long long ll;
typedef long double dl;
typedef unsigned long long ull;
const int SZ=5e5+7,MSZ=2e5+7;
const ll INF=1e18+7;
const dl eps=1e-18;
int MOD=1e9+7;
ll trig(ll n){
    return n*(n+1)/2;
}
int getN(){
    int n;cin >> n;
    return n;
}
int n,m,k;
ll B[107][1007],S[107][1007],F[107][107],C[107][107],dp[107][9907];
void FLOYED(){
    for(int X=0;X<=n+1;X++){
        for(int i=0;i<=n+1;i++){
            for(int j=0;j<=n+1;j++){
                F[i][j]=min(F[i][j],F[i][X]+F[X][j]);
            }
        }
    }
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen("optmilk.in","r",stdin);
    //freopen("optmilk.out","w",stdout);
    //cout << fixed << setprecision(12);
    int tt=1;
    //cin >> tt;
    LOOP(tt){
        cin >> n >> m >> k;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=k;j++)cin >> B[i][j] >> S[i][j];
            for(int j=1;j<=n;j++){
                if(i==j)F[i][j]=0;
                else F[i][j]=INF;
            }
        }
        F[0][0]=F[n+1][n+1]=0;
        F[0][n+1]=F[n+1][0]=INF;
        for(int i=1;i<=n;i++){
            F[0][i]=F[i][n+1]=1;
            F[i][0]=F[n+1][i]=INF;

        }
        int mxW=0;
        LOOP(m){
            int x,y,w;cin >> x >> y >> w;
            F[x][y]=w;
            mxW=max(mxW,w);
        }
        FLOYED();
        if(mxW>1||n>50||k>50){
            ll ans=0;
            for(int v=1;v<=n;v++){
                for(int i=1;i<=n;i++){
                    if(v==i)continue;
                    for(int j=1;j<=k;j++){
                        if(S[i][j]==-1||B[v][j]==-1)continue;
                        ans=max(ans,(S[i][j]-B[v][j])/(F[v][i]+F[i][v]));
                    }
                }
            }
            cout << ans;
        }
        for(int v=1;v<=n;v++){
            for(int i=1;i<=n;i++){
                if(v==i)continue;
                for(int j=1;j<=k;j++){
                    if(S[i][j]==-1||B[v][j]==-1)continue;
                    C[v][i]=max(C[v][i],S[i][j]-B[v][j]);
                }
            }
        }
        ll ans=0;
        for(int X=1;X<=n;X++){
            for(int T=0;T<100;T++){
                if(T==0){
                    for(int i=1;i<=n;i++)dp[i][0]=-INF;
                    dp[X][0]=0;
                    continue;
                }
                for(int nd=1;nd<=n;nd++){
                    dp[nd][T]=-INF;
                    for(int pr=1;pr<=n;pr++){
                        if(pr==nd)continue;
                        if(F[pr][nd]>T)continue;
                        if(dp[pr][T-F[pr][nd]]==-INF)continue;
                        dp[nd][T]=max(dp[nd][T],dp[pr][T-F[pr][nd]]+C[pr][nd]);
                    }
                }
                ans=max(ans,dp[X][T]/T);
            }
        }
        cout << ans;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 73ms
memory: 12612kb

input:

100 181 1000
553730496 158361961 892706912 178296397 743382683 297380306 641674485 99624440 917350062 18856036 844421978 187895310 648680590 312745394 560991872 402321479 712754581 166489560 776432653 57402415 554268728 511597509 861517186 541462029 843246768 457630601 923371196 521104850 557772066 ...

output:

10

result:

wrong answer 1st lines differ - expected: '1', found: '10'

Subtask #2:

score: 0
Wrong Answer

Test #14:

score: 21
Accepted
time: 18ms
memory: 10216kb

input:

50 50 20
1000000000 94476 1000000000 75837 1000000000 27079 1000000000 129004 1000000000 100830 1000000000 98560 1000000000 99302 1000000000 65993 30410 1 1000000000 66183 1000000000 89148 1000000000 21236 1000000000 11935 1000000000 53895 1000000000 126490 1000000000 104741 1000000000 78615 1000000...

output:

1003

result:

ok single line: '1003'

Test #15:

score: 0
Accepted
time: 18ms
memory: 10244kb

input:

50 50 10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 339508586 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

15782746

result:

ok single line: '15782746'

Test #16:

score: -21
Wrong Answer
time: 14ms
memory: 9936kb

input:

50 50 50
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 12 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10000 10000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

199

result:

wrong answer 1st lines differ - expected: '203', found: '199'

Subtask #3:

score: 0
Wrong Answer

Test #37:

score: 0
Wrong Answer
time: 119ms
memory: 12148kb

input:

100 243 1000
969713863 380451398 977287381 546839551 578242281 267067963 834635238 316438277 806980243 189648353 779415475 453867771 741678190 352485450 473763928 190177433 687118672 377243148 644333594 197290749 949048287 436673078 690006797 180711316 714366028 387342721 980055654 198167471 8873988...

output:

00

result:

wrong answer 1st lines differ - expected: '28', found: '00'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%