QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#384710 | #6845. Tax | wsc2008 | WA | 0ms | 4004kb | C++14 | 1.3kb | 2024-04-10 11:04:03 | 2024-04-10 11:04:03 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
inline ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*f;
}
inline void write(ll x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
}
const ll N=55;
ll n,m,W[N],d[N],cnt[N],ans[N];
vector<pii>to[N],es[N];
void dfs(ll x,ll s){
ans[x]=min(ans[x],s);
for(pii e:es[x]){
ll y=e.first,w=e.second;
cnt[w]++;
dfs(y,s+cnt[w]*W[w]);
cnt[w]--;
}
}
bool Med;
int main(){
cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
n=read(),m=read();
rep(i,1,m)W[i]=read();
rep(i,1,n)ans[i]=1e18;
rep(i,1,m){
ll x=read(),y=read(),z=read();
to[x].push_back(make_pair(y,z));
to[y].push_back(make_pair(x,z));
}
queue<ll>q;
q.push(1),d[1]=1;
while(!q.empty()){
ll u=q.front();q.pop();
for(pii e:to[u]){
ll v=e.first,w=e.second;
if(!d[v]){
d[v]=d[u]+1;
es[u].push_back(make_pair(v,w));
q.push(v);
}
}
}
dfs(1,0);
rep(i,2,n)write(ans[i]),putchar('\n');
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
5 6 1 8 2 1 3 9 1 2 1 2 3 2 1 4 1 3 4 6 3 5 4 4 5 1
output:
1 9 1 3
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
10 15 730 2163 6818 4647 9699 1037 2034 8441 2619 6164 464 4369 4500 6675 1641 1 6 2 3 6 1 3 2 1 9 2 2 7 3 1 6 5 1 5 3 2 3 10 1 10 2 2 5 10 1 8 2 2 9 8 1 7 4 2 4 5 2 4 10 2
output:
4353 2893 7219 2893 2163 4353 8679 8679 4353
result:
ok 9 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
10 15 847 2302 8846 8055 585 6541 6493 7165 5376 8551 836 2993 2700 9323 5119 2 1 5 2 3 3 3 10 3 10 4 3 8 3 4 10 8 1 3 7 3 4 5 3 5 8 5 6 3 3 8 6 2 6 5 4 9 10 2 7 9 4 5 9 4
output:
585 9431 53661 18656 27123 27123 17486 29425 27123
result:
ok 9 lines
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3860kb
input:
20 30 4547 9278 5093 443 7292 7570 7138 9315 4114 723 9854 9584 294 1861 5478 2734 5967 7102 6137 9504 456 7980 9645 6571 336 5308 1035 8008 3128 4035 7 1 2 11 7 1 11 12 2 12 10 2 10 5 2 20 5 1 20 17 2 17 16 2 16 18 1 7 19 3 19 12 1 2 18 2 3 7 1 12 3 1 19 3 1 13 11 1 12 13 1 19 13 1 13 3 2 18 15 2 8...
output:
287066 13825 166452 97327 37474 9278 41475 65308 60215 13825 32381 22919 24557 287066 208479 152811 222120 14371 106421
result:
wrong answer 1st lines differ - expected: '166078', found: '287066'