QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#571226#6527. CyberlandLe0ChanCompile Error//C++202.8kb2024-09-17 21:16:052024-09-17 21:16:13

Judging History

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

  • [2024-09-17 21:16:13]
  • 评测
  • [2024-09-17 21:16:05]
  • 提交

answer

#include "cyberland.h"

#include <cassert>
#include <cstdio>

#include <vector>
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr);
int main() {
  int T;
  assert(1 == scanf("%d", &T));
  while (T--){
    int N,M,K,H;
    assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
    std::vector<int> x(M);
    std::vector<int> y(M);
    std::vector<int> c(M);
    std::vector<int> arr(N);
    for (int i=0;i<N;i++)
      assert(1 == scanf("%d", &arr[i]));
    for (int i=0;i<M;i++)
      assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
    printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr));
  }
}

#include <bits/stdc++.h>
using namespace std;
namespace Le0{
const int N=1e5+5,M=6e6+5;
#define fi first 
#define se second
#define db double
int n,m,K,t;
int a[N];
db dis[M];
bool vis2[M],vis[M];
tuple<int,int,int> b[N];
vector<pair<int,db>> g[M];
void add(int x,int y,db c){g[x].push_back({y,c});}
int gc(int x,int y){return x*n+y;}
int gt(int x){
	return x%n==0?n:x%n;
}
void dfs(int x){
    vis2[x]=1;
    for(auto [y,w]:g[x]){
        if(gt(y)!=t&&!vis2[y]){
            dfs(y);
        }
    }
}
void dijk(int s){
    priority_queue<pair<db,int>> q;
    q.push({0,s});
    for(int i=1;i<=gc(K,n);i++) dis[i]=1e18;
    dis[s]=0;
    while(q.size()){
        auto [v,x]=q.top();q.pop();
        if(vis[x]) continue;
        vis[x]=1;
        for(auto [y,w]:g[x]){
            if(dis[y]>dis[x]+w){
                dis[y]=dis[x]+w;
                q.push({-dis[y],y});
            }
        }
    }
}
db main(){
    K=min(K,67);
    for(int i=1;i<=n;i++){
        for(int j=0;j<=K;j++){
            g[gc(j,i)].clear(),vis[gc(j,i)]=vis2[gc(j,i)]=0;
        }
    }
    for(int i=1;i<=m;i++){
        auto [x,y,c]=b[i];
		// cout<<x<<' '<<y<<" "<<c<<"\n";
        for(int j=0;j<=K;j++){
            add(gc(j,x),gc(j,y),c*1.0/(1<<j));
            add(gc(j,y),gc(j,x),c*1.0/(1<<j));
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i]==2){
            for(int j=0;j<K;j++){
                add(gc(j,i),gc(j+1,i),0);
            }
        }
    }
    dfs(gc(0,1));
    dijk(gc(0,t));
    db ans=1e18;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=K;j++){
            if(a[i]==0||i==1){
                if(vis2[gc(j,i)]){
                    ans=min(ans,dis[gc(j,i)]);
                }
            }
        }
    }
    return ans==1e18?-1:ans;
}
}
double solve(int n, int m, int K, int t, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr){
    Le0::n=n;Le0::m=m;Le0::K=K;Le0::t=t+1;
    for(int i=0;i<m;i++){
        Le0::b[i+1]={x[i]+1,y[i]+1,c[i]};
    }
    for(int i=0;i<n;i++) Le0::a[i+1]=arr[i];
    return Le0::main();
}

Details

/usr/bin/ld: /tmp/ccOXlKH4.o: in function `main':
answer.code:(.text.startup+0x810): multiple definition of `main'; /tmp/ccWSn5F4.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status