QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#738632 | #8038. Hammer to Fall | scallionsong | WA | 70ms | 12572kb | C++14 | 2.6kb | 2024-11-12 19:35:48 | 2024-11-12 19:35:49 |
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 int INF=0x3f3f3f3f;
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;
bool vis[100010];
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;});
F(i,1,n) vis[i]=0;
}
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;
for(auto i:e[x]){
chkmin(f[x],f[i.fir]+i.sec);
if((int)e[x].size()>sq&&!vis[i.fir]) break;
}
}
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6624kb
input:
3 2 2 1 1 1 2 3 10 1 2 1 3 2
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 1ms
memory: 7032kb
input:
2 1 10 5000 5000 1 2 10000 1 2 2 1 2 2 1 1 1 2
output:
550000000
result:
ok single line: '550000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7796kb
input:
10 10 10 5 14 99 14 18 4 58 39 48 60 2 4 4 6 9 56 10 8 34 7 5 96 1 3 26 3 7 92 6 8 4 5 1 72 7 6 39 7 2 93 8 8 9 10 2 2 5 9 2 3
output:
8810
result:
ok single line: '8810'
Test #4:
score: 0
Accepted
time: 2ms
memory: 7672kb
input:
100 500 10000 89 61 65 85 89 2 32 97 13 70 29 86 68 74 84 64 54 39 26 84 56 95 73 11 70 26 60 40 84 58 68 33 65 71 55 2 11 71 49 85 14 59 38 11 60 8 81 78 27 32 52 49 35 94 62 72 64 50 12 45 77 74 92 67 92 38 81 39 12 29 60 70 53 33 25 60 7 83 4 85 47 32 13 58 85 86 44 68 44 1 81 62 97 7 66 62 5 16 ...
output:
609241
result:
ok single line: '609241'
Test #5:
score: -100
Wrong Answer
time: 70ms
memory: 12572kb
input:
100000 100000 100000 134299012 740620432 241626312 533601686 901212368 274154852 46613593 72208460 685661661 930069933 934386896 140544225 900179749 8735320 54649110 922673925 450551589 517879800 773426781 410723403 783459037 344315202 75310230 122339501 113898579 646500753 18238713 119326471 969272...
output:
211430061
result:
wrong answer 1st lines differ - expected: '641103242', found: '211430061'