QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212195#5407. 基础图论练习题Rong70 8ms5948kbC++143.0kb2023-10-13 11:19:412023-10-13 11:19:42

Judging History

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

  • [2023-10-13 11:19:42]
  • 评测
  • 测评结果:0
  • 用时:8ms
  • 内存:5948kb
  • [2023-10-13 11:19:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int T, n, RP;
int E[5005][5005], d[5005], fw[5005], fr[5005], to[5005];
char s[2005];
long long Ans, ton[5005], tonu[5005], tond[5005];
pair < int , int > r[5005];
int Represent (char a){
    if (a >= '0' && a <= '9')
        return a - '0';
    else
        return 10 + a - 'A';
}
void Add (int u, int v){
    E[u][v] = 1;
    E[v][u] = - 1;
    ++ d[v];
}
const long long mod = 1e9 + 7;
long long Qpow (long long a, long long p){
    long long Res = 1;
    while (p > 0){
        if (p & 1)
            Res = Res * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return Res;
}
void Clear (){
    Ans = 0;
    RP = 0;
    for (int i = 1;i <= n;++ i)
        ton[i] = tonu[i] = tond[i] = d[i] = 0;
}
int main (){
    scanf ("%d", &T);
    while (T --){
        scanf ("%d", &n);
        for (int i = 2;i <= n;++ i){
            int l = (i - 1) / 4 + 1;
            scanf ("\n%s", s + 1);
            for (int j = 1;j <= l;++ j){
                for (int k = 4 * j - 3, x = Represent (s[j]);k <= 4 * j && k < i;++ k, x >>= 1)
                    if (x & 1)
                        Add (i, k);
                    else
                        Add (k, i);
            }
        }
        for (int i = 1;i <= n;++ i)
            r[i] = make_pair (d[i], i);
        sort (r + 1, r + n + 1);
        int Res = 0;
        int frt = 1;
        for (int i = 1;i <= n;++ i){
            Res += r[i].first;
            to[r[i].second] = i;
            if (r[frt].first != r[i].first)
                frt = i;
            fr[i] = frt;
            if (Res == i * (i - 1) / 2)
                ton[i] = 1, ++ RP;
            if (Res == i * (i - 1) / 2 + 1)
                tonu[i] = 1;
            if (Res == i * (i - 1) / 2 - 1)
                tond[i] = 1;
        }
        int las = n;
        for (int i = n;i >= 1;-- i){
            if (r[i].first != r[las].first)
                las = i;
            fw[i] = las;
        }
        for (int i = 1;i <= n;++ i){
            ton[i] += ton[i - 1];
            tond[i] += tond[i - 1];
            tonu[i] += tonu[i - 1];
        }
        for (int i = 1;i <= n;++ i){
            long long w = Qpow (2, (i - 1) * (i - 2) / 2);
            for (int j = 1;j < i;++ j){
                int u = i, v = j;
                if (E[u][v] < 0)
                    swap (u, v);
                long long p = RP;
                u = to[u];
                v = to[v];
                if (fw[u] != fr[v] - 1){
                    if (fw[u] < fr[v])
                        p += - (ton[fr[v] - 1] - ton[fw[u] - 1]) + tond[fr[v] - 1] - tond[fw[u] - 1];
                    else
                        p += - (ton[fw[u] - 1] - ton[fr[v] - 1]) + tonu[fw[u] - 1] - tonu[fr[v] - 1];
                }
                (Ans += w * p % mod) %= mod;
                (w <<= 1) %= mod;
            }
        }
        printf ("%lld\n", Ans);
        Clear ();
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 5948kb

input:

10000
100
1
2
2
8
C0
F0
27
78
AE1
C01
511
D87
EF20
3873
2742
73D0
DC9B0
FB2A3
9C011
9B4E0
95DC00
A7B980
F43531
6A6245
5347BE0
1A6C8A1
88E46D6
64CF3AE
D25F63C1
C894E4C3
1C0AFD73
EC1C3F9A
087CE17C0
22149A380
B28038AF1
B9CA21C7F
D78F5307C1
49045489A2
72C4DE6FD1
7713F40D05
EEE8878EEC1
310E62812B1
DA9D5B...

output:

281603732
13
285212672
371842543
84
0
1983
2
268505087
268435455
719476515
32785
2
719476771
123
2621567
2971
0
719476275
371842543
2097159
41087
34815
4185088
719478307
502774910
719476267
719476259
719476259
77641
268697613
719477283
36863
2171007
719476259
371842543
120
84
230
5769215
268435455
1...

result:

wrong answer 17th numbers differ - expected: '2523', found: '2971'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%