QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234143#1965. TrioBUET_Twilight#WA 1ms3972kbC++232.7kb2023-11-01 14:29:052023-11-01 14:29:05

Judging History

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

  • [2023-11-01 14:29:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3972kb
  • [2023-11-01 14:29:05]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
#define int long long
#define ll long long 
#define lll __int128_t
#define pb push_back
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

const int M = 10;
vector<vector<bitset<M>>> calc(vector<int> arr) {
    bitset<M> fre[2][10];
    for(int i = 0; i < arr.size(); i++) {
        fre[0][arr[i] % 10][i] = 1;
        fre[1][arr[i] / 10][i] = 1;
    }
    vector<vector<bitset<M>>> res(100, vector<bitset<M>>(100, 0));
    for(int i = 11; i <= 99; i++) {
        if(i % 10 == 0) continue;
        for(int j = 11; j <= 99; j++) {
            if(j % 10 == 0) continue;

            int a = i / 10, b = i % 10;
            int e = j / 10, f = j % 10;

            if(a == e) {
                res[i][j] |= (fre[1][a]);
            }
            else {
                for(int k = 1; k <= 9; k++) {
                    if(k == a or k == e) continue;
                    res[i][j] |= (fre[1][k]);
                }
            }
            if(b == f) {
                res[i][j] &= (fre[0][b]);
            }
            else {
                bitset<M> tmp = 0;
                for(int k = 1; k <= 9; k++) {
                    if(k == b or k == f) continue;
                    tmp |= (fre[0][k]);
                }
                res[i][j] &= tmp;
            }
        }
    }
    return res;
}

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> fp, sp;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        fp.push_back(a[i] / 100);
        sp.push_back(a[i] % 100);
    }
    auto fcalc = calc(fp);
    auto scalc = calc(sp); 
    bitset<M> x;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j) continue;
            x = (fcalc[fp[i]][fp[j]] & scalc[sp[i]][sp[j]]);
            //cout << x.to_string() << "\n";
            x[i] = 0;
            x[j] = 0;
            ans += x.count();
        }
    }
    //cout << ans << "\n";
    cout << ans / 6 << "\n";
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    solve();
    return 0;
}

詳細信息

Test #1:

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

input:

4
1234
2345
3456
4567

output:

4

result:

ok single line: '4'

Test #2:

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

input:

9
1299
2399
3499
4599
5699
6799
7899
8999
9199

output:

84

result:

ok single line: '84'

Test #3:

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

input:

9
1239
2349
3459
4569
5679
6789
7899
8919
9129

output:

84

result:

ok single line: '84'

Test #4:

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

input:

9
1999
2999
3999
4999
5999
6999
7999
8999
9999

output:

84

result:

ok single line: '84'

Test #5:

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

input:

9
1234
2345
3456
4567
5678
6789
7891
8912
9123


output:

84

result:

ok single line: '84'

Test #6:

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

input:

18
1211
2311
3411
4511
5611
6711
7811
8911
9111
1222
2322
3422
4522
5622
6722
7822
8922
9122

output:

168

result:

ok single line: '168'

Test #7:

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

input:

17
1211
2311
3411
4511
5611
6711
7811
8911
9111
1231
2341
3451
4561
5671
6781
7891
9121

output:

336

result:

ok single line: '336'

Test #8:

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

input:

81
1211
2311
3411
4511
5611
6711
7811
8911
9111
1222
2322
3422
4522
5622
6722
7822
8922
9122
1233
2333
3433
4533
5633
6733
7833
8933
9133
1244
2344
3444
4544
5644
6744
7844
8944
9144
1255
2355
3455
4555
5655
6755
7855
8955
9155
1266
2366
3466
4566
5666
6766
7866
8966
9166
1277
2377
3477
4577
5677
67...

output:

39405

result:

wrong answer 1st lines differ - expected: '43848', found: '39405'