QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#533755#8760. 不等式qwetlWA 5ms26220kbC++172.0kb2024-08-26 12:49:002024-08-26 12:49:01

Judging History

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

  • [2024-08-26 12:49:01]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:26220kb
  • [2024-08-26 12:49:00]
  • 提交

answer

#include <bits/stdc++.h>
#define Ciallo main
using namespace std;
const int N = 4e6;

inline int read(){
    int _x = 0, _w = 1;
    char ch = 0;
    while(ch < '0' || ch > '9') {
        if(ch == '-') _w = -1;
#ifdef __linux__
        ch = (char)getchar_unlocked();
#else
        ch = (char) _getchar_nolock();
#endif
    }
    while(ch >= '0' && ch <= '9') {
        _x = (_x << 3) + (_x << 1) + (ch - '0');
#ifdef __linux__
        ch = (char)getchar_unlocked();
#else
        ch = (char) _getchar_nolock();
#endif
    }
    return _x * _w;
}

inline void write(int _x){
    if(_x < 0) {
#ifdef __linux__
        putchar_unlocked('-');
#else
        _putchar_nolock('-');
#endif
        _x = -_x;
    }
    static int _sta[130];
    int _top = 0;
    do {
        _sta[_top++] = _x % 10, _x /= 10;
    } while(_x);
    while(_top)
#ifdef __linux__
        putchar_unlocked(_sta[--_top] + 48);
    putchar_unlocked('\n');
#else
        _putchar_nolock(_sta[--_top] + 48);
    _putchar_nolock('\n');
#endif
}

int n, m, sum, x, y, z;
int e[N], h[N], ne[N], idx, p[N];
int w[N], cnt;
int q[N], d[N], hh, tt;

inline void add(int _a, int _b, int _c){
    e[idx] = _b, p[idx] = _c, ne[idx] = h[_a], h[_a] = idx++;
}

void topoSort(){
    for(int i = 1; i <= n + cnt; i++)
        if(!d[i]) {
            q[tt++] = i;
            w[i] = 1;
        }

    while(hh < tt) {
        int t = q[hh++];
        for(int i = h[t]; i != -1; i = ne[i]) {
            int j = e[i];
            w[j] = max(w[j], w[t] + w[p[i]]);
            d[j]--;
            if(!d[j])
                q[tt++] = j;
        }
    }
}

signed Ciallo(){
    memset(h, -1, sizeof h);
    n = read(), m = read();
    while(m--) {
        x = read(), y = read(), z = read();
        add(y, x, z), add(z, x, y);
        d[x] += 2;
    }

    topoSort();
    for(int i = 1; i <= n; i++)
//        write(w[i]);
        sum += w[i];
    write(sum);

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 24100kb

input:

3 1
1 2 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 26160kb

input:

3 1
1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 0ms
memory: 26200kb

input:

3 1
1 2 2

output:

4

result:

ok 1 number(s): "4"

Test #4:

score: 0
Accepted
time: 0ms
memory: 26220kb

input:

3 1
1 2 2

output:

4

result:

ok 1 number(s): "4"

Test #5:

score: 0
Accepted
time: 0ms
memory: 24100kb

input:

3 1
1 2 2

output:

4

result:

ok 1 number(s): "4"

Test #6:

score: 0
Accepted
time: 0ms
memory: 24020kb

input:

5 1
1 2 2

output:

6

result:

ok 1 number(s): "6"

Test #7:

score: 0
Accepted
time: 0ms
memory: 26140kb

input:

5 1
1 2 2

output:

6

result:

ok 1 number(s): "6"

Test #8:

score: 0
Accepted
time: 0ms
memory: 24176kb

input:

5 1
1 2 2

output:

6

result:

ok 1 number(s): "6"

Test #9:

score: 0
Accepted
time: 0ms
memory: 26144kb

input:

5 1
1 2 3

output:

6

result:

ok 1 number(s): "6"

Test #10:

score: 0
Accepted
time: 0ms
memory: 24172kb

input:

5 2
1 2 3
2 3 4

output:

8

result:

ok 1 number(s): "8"

Test #11:

score: 0
Accepted
time: 0ms
memory: 26096kb

input:

10 1
1 2 3

output:

11

result:

ok 1 number(s): "11"

Test #12:

score: 0
Accepted
time: 5ms
memory: 26136kb

input:

10 1
1 2 2

output:

11

result:

ok 1 number(s): "11"

Test #13:

score: 0
Accepted
time: 0ms
memory: 24172kb

input:

10 2
1 2 3
2 3 4

output:

13

result:

ok 1 number(s): "13"

Test #14:

score: 0
Accepted
time: 0ms
memory: 24048kb

input:

10 2
1 2 2
2 3 4

output:

14

result:

ok 1 number(s): "14"

Test #15:

score: 0
Accepted
time: 4ms
memory: 24028kb

input:

10 3
1 2 3
1 8 8
2 3 3

output:

13

result:

ok 1 number(s): "13"

Test #16:

score: 0
Accepted
time: 0ms
memory: 26152kb

input:

20 1
1 2 2

output:

21

result:

ok 1 number(s): "21"

Test #17:

score: 0
Accepted
time: 0ms
memory: 24084kb

input:

20 2
1 2 3
2 3 3

output:

23

result:

ok 1 number(s): "23"

Test #18:

score: 0
Accepted
time: 0ms
memory: 26072kb

input:

20 3
7 14 6
1 2 3
4 7 20

output:

24

result:

ok 1 number(s): "24"

Test #19:

score: -100
Wrong Answer
time: 0ms
memory: 26096kb

input:

20 4
1 2 2
6 10 6
2 3 3
3 4 5

output:

31

result:

wrong answer 1st numbers differ - expected: '-1', found: '31'