QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#409893#6845. TaxDecadeWA 1ms3764kbC++202.3kb2024-05-12 21:16:422024-05-12 21:16:43

Judging History

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

  • [2024-05-12 21:16:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3764kb
  • [2024-05-12 21:16:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define double long double
typedef long long ull;
typedef unsigned long long uull;
typedef pair<int, int> PII;
typedef pair<int,PII> PIII;
// typedef __int128 lll;
// mt19937 rnd1(random_device{}());
// mt19937_64 rnd2(random_device{}());
// uniform_int_depthtribution<int> deptht1(0,2e18);    //定义deptht1为0——100的随机整数
// uniform_real_depthtribution<double> deptht2(-10,10);    //定义deptht2为-10——10的随机浮点数
//#define mp make_pair
//fflush(stdout);
//random_shuffle()
//mod = 1e9+7+rand() 哈希时的随机模数
const int mod = 998244353,INF = 1e9;
ull qpow(ull a, ull b)
{
    ull res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int N = 110,M = 5010;

int w[M],d[N],vis[10010],dis[N];
int h[N],id[M<<1],ne[M<<1],v[M<<1],idx = 1;

void add(int x,int y,int z)
{
    id[idx] = z,v[idx] = y,ne[idx] = h[x],h[x] = idx++;
}

void bfs(int u)
{
    queue<int> q;
    d[u] = 1;
    q.push(u);
    while(q.size())
    {
        int t = q.front();
        q.pop();
        for(int i=h[t];i;i=ne[i])
        {
            int j = v[i];
            if(d[j]) continue;
            d[j] = d[t]+1;
            q.push(j);
        }
    }
}

void dfs(int u)
{
    for(int i=h[u];i;i=ne[i])
    {
        int j = v[i];
        if(d[j]!=d[u]+1) continue;
        vis[id[i]]++;
        dis[j] = min(dis[j],dis[u]+vis[id[i]]*w[id[i]]);
        dfs(j);
        vis[id[i]]--;
    }
}

void solve()
{
    int n,m;
    cin>>n>>m;
    memset(dis,0x3f,sizeof(dis));
    for(int i=1;i<=m;i++) cin>>w[i];
    for(int i=1;i<=m;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        add(a,b,c);
        add(b,a,c);
    }
    dis[1] = 0;
    bfs(1);
    dfs(1);
    for(int i=2;i<=n;i++) cout<<dis[i]<<'\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3540kb

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: 1ms
memory: 3748kb

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: 3764kb

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: 1ms
memory: 3692kb

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:

157352
13825
87859
41653
24011
9278
28012
33105
37474
13825
18918
18918
24557
157352
102052
74218
115693
14371
50747

result:

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