QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387295#8195. Satelityjames1BadCreeper0 2ms4404kbC++142.1kb2024-04-12 12:04:342024-04-12 12:04:34

Judging History

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

  • [2024-04-12 12:04:34]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:4404kb
  • [2024-04-12 12:04:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std; 
typedef unsigned long long u64; 
const u64 B = 10007; 

int n, PP, M, pw[10]; 
mt19937_64 Rand(time(0)); 
u64 ha[1005], vl[1005], p[2005]; 
vector<char> ans[2005]; 
set<int> Q[1005]; 
map<u64, vector<int>> mp; 
int fa[1005]; 
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

int main(void) {
    ios::sync_with_stdio(0); 
    for (int i = p[0] = 1; i <= 2000; ++i) p[i] = p[i - 1] * B; 
    for (int i = pw[0] = 1; i <= 10; ++i) pw[i] = pw[i - 1] * 3; 

    cin >> n >> PP >> M; 
    for (int i = 1; i <= n; ++i) ans[i].push_back('A'), ans[i + n].push_back('B'); 
    for (int i = 1; i <= n; ++i) vl[i] = Rand(); 
    while (PP--) {
        int x, y; cin >> x >> y; 
        if (x > y) swap(x, y); 
        Q[x].insert(y); 
        ha[x] += vl[y - n]; 
    }
    for (int i = 1; i <= n; ++i) fa[i] = i; 
    for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j)
        if (ha[i] == ha[j]) fa[find(j)] = find(i); 

    for (int i = 1; i <= n; ++i) if (find(i) == i) {
        for (int j = 1; j <= n; ++j) 
            if (find(i) == find(j)) ans[j].push_back('A'); 
            else ans[j].push_back('B'); 

        for (int j = 1; j <= n; ++j)
            if (Q[i].count(j + n)) ans[j + n].push_back('A'); 
            else ans[j + n].push_back('C'); 
    }

    for (int i = 1; i <= n * 2; ++i) {
        u64 val = 0; 
        for (int j = 0; j < ans[i].size(); ++j)
            val = val * B + ans[i][j]; 
        mp[val].push_back(i); 
    }
    int mx = 0; 
    for (const auto& [x, y] : mp) mx = max(mx, int(y.size())); 
    cerr << mx << "\n"; 

    int t = 0, res = 1; 
    while (res < mx) res *= 3, ++t; 
    for (const auto& [x, y] : mp) 
        for (int i = 0; i < y.size(); ++i)
            for (int j = t - 1; j >= 0; --j)
                ans[y[i]].push_back(char((i / pw[j]) % 3 + 'A')); 

    cout << ans[1].size() << '\n'; 
    for (int i = 1; i <= n * 2; ++i) {
        for (int j = 0; j < ans[1].size(); ++j) cout << ans[i][j]; 
        cout << '\n'; 
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 7
Accepted
time: 2ms
memory: 4168kb

input:

100 5340 10200
1 101
1 102
1 104
1 105
1 106
1 107
1 108
1 109
1 116
1 119
1 120
1 123
1 125
1 126
1 127
1 129
1 132
1 133
1 135
1 136
1 137
1 138
1 141
1 144
1 146
1 147
1 148
1 149
1 151
1 155
1 156
1 158
1 159
1 160
1 161
1 163
1 165
1 167
1 168
1 169
1 170
1 172
1 173
1 174
1 175
1 177
1 178
1 1...

output:

101
AABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
ABABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
ABBABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 4024kb

input:

100 658 10200
1 104
1 148
1 169
1 175
1 177
1 181
1 187
1 188
2 132
2 190
3 119
3 147
3 154
3 163
3 165
3 177
3 184
3 199
4 102
4 105
4 130
4 132
4 138
4 160
4 183
4 192
4 199
5 113
5 152
5 153
5 165
5 186
5 194
6 111
6 114
6 134
6 155
6 199
7 109
7 120
7 128
7 131
7 136
7 143
7 191
8 104
8 107
8 17...

output:

101
AABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
ABABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
ABBABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok correct

Test #3:

score: 0
Accepted
time: 2ms
memory: 4320kb

input:

100 9540 10200
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146
1 147
1 148
1 1...

output:

101
AABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
ABABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
ABBABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok correct

Test #4:

score: 0
Accepted
time: 2ms
memory: 4404kb

input:

100 10000 10200
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146
1 147
1 ...

output:

7
AAAAAAA
AAAAAAB
AAAAAAC
AAAAABA
AAAAABB
AAAAABC
AAAAACA
AAAAACB
AAAAACC
AAAABAA
AAAABAB
AAAABAC
AAAABBA
AAAABBB
AAAABBC
AAAABCA
AAAABCB
AAAABCC
AAAACAA
AAAACAB
AAAACAC
AAAACBA
AAAACBB
AAAACBC
AAAACCA
AAAACCB
AAAACCC
AAABAAA
AAABAAB
AAABAAC
AAABABA
AAABABB
AAABABC
AAABACA
AAABACB
AAABACC
AAABBAA
AA...

result:

ok correct

Test #5:

score: -7
Wrong Answer
time: 0ms
memory: 3848kb

input:

100 1 10200
91 111

output:

8
AABAAAAA
AABAAAAB
AABAAAAC
AABAAABA
AABAAABB
AABAAABC
AABAAACA
AABAAACB
AABAAACC
AABAABAA
AABAABAB
AABAABAC
AABAABBA
AABAABBB
AABAABBC
AABAABCA
AABAABCB
AABAABCC
AABAACAA
AABAACAB
AABAACAC
AABAACBA
AABAACBB
AABAACBC
AABAACCA
AABAACCB
AABAACCC
AABABAAA
AABABAAB
AABABAAC
AABABABA
AABABABB
AABABABC
A...

result:

wrong answer detected: (1, 101) are connected

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%