QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#738691 | #8038. Hammer to Fall | scallionsong | WA | 0ms | 6460kb | C++14 | 2.5kb | 2024-11-12 19:44:06 | 2024-11-12 19:44:13 |
Judging History
answer
bool M1;
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define LL __int128
#define db double
#define LD long double
#define Pii pair<int,int>
#define Pll pair<ll,ll>
#define Pull pair<ull,ull>
#define Pdb pair<db,db>
#define fir first
#define sec second
#define vec vector<int>
#define pb push_back
#define qlr cerr<<"qlr\n"
#define dyh cerr<<"dyh\n"
#define pc(x) __builtin_popcount(x)
#define uni(x,y) uniform_int_distribution<int>(x,y)(rng)
#define unl(x,y) uniform_int_distribution<ll>(x,y)(rng)
#define unr(x,y) uniform_real_distribution<double>(x,y)(rng)
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define UF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define look_memory cerr<<'\n'<<abs(&M1-&M2)/1024.0/1024<<'\n'
#define look_time cerr<<'\n'<<clock()*1.0/CLOCKS_PER_SEC<<'\n'
mt19937 rng(time(0)^(*new int));
const ll INF=0x3f3f3f3f3f3f3f3f;
const int Mod=998244353;
template<typename T>
inline void inc(T &a,T b){
if(b<0) b+=Mod;
a+=b;
if(a>=Mod) a-=Mod;
}
template<typename T>
inline void dec(T &a,T b){
if(b<0) b+=Mod;
a-=b;
if(a<0) a+=Mod;
}
template<typename T>
inline void muc(T &a,T b){
a=a*b%Mod;
}
template<typename T>
inline bool chkmin(T &a,T b){
if(a<=b) return false;
a=b;
return true;
}
template<typename T>
inline bool chkmax(T &a,T b){
if(a>=b) return false;
a=b;
return true;
}
int n,m,q,sq;
ll ans;
int qry[100010];
ll a[100010],f[100010];
vector<Pii> e[100010];
void rebuild(){
F(i,1,n) if((int)e[i].size()>sq) nth_element(e[i].begin(),e[i].begin()+sq,e[i].end(),[&](Pii cm1,Pii cm2){return f[cm1.fir]+cm1.sec<f[cm2.fir]+cm2.sec;});
}
bool M2;
int main(){
// freopen("count.in","r",stdin);
// freopen("count.out","w",stdout);
srand(time(0)^(*new int));
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>q;sq=317;
F(i,1,n) cin>>a[i];
F(i,1,m){
int x,y,z;
cin>>x>>y>>z;
e[x].pb({y,z});
e[y].pb({x,z});
}
F(i,1,q) cin>>qry[i];
F(i,1,n) f[i]=0;
UF(i,q,1){
if(!((q-i)%sq)) rebuild();
int x=qry[i];
f[x]=INF;
F(i,0,min((int)e[i].size()-1,sq)) chkmin(f[x],f[e[x][i].fir]+e[x][i].sec);
}
F(i,1,n) f[i]%=Mod;
F(i,1,n) ans=(ans+a[i]*f[i])%Mod;
cout<<ans;
look_memory;
look_time;
return 0;
}
/*
g++ C1.cpp -o C1 -std=c++14 -O2&&./C1
3 2 2
1 1 1
2 3 10
1 2 1
3 2
2 1 10
5000 5000
1 2 10000
1 2 2 1 2 2 1 1 1 2
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6460kb
input:
3 2 2 1 1 1 2 3 10 1 2 1 3 2
output:
448799245
result:
wrong answer 1st lines differ - expected: '12', found: '448799245'