QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#257932#1965. Triodel17TL 515ms5796kbC++204.7kb2023-11-19 13:51:372023-11-19 13:51:40

Judging History

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

  • [2023-11-19 13:51:40]
  • 评测
  • 测评结果:TL
  • 用时:515ms
  • 内存:5796kb
  • [2023-11-19 13:51:37]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef __int128 Int;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef pair<ll, ii> iii;
typedef unordered_map<ll, ll> unmap;

template<typename T> using pqmax = priority_queue<T>;
template<typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using oset = tree<T, null_type,less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fi first
#define se second
#define sz size()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define lg(n) (ll)__lg(n)
#define btpc __builtin_popcount

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define FOR(i,a,b) for(ll i = a; i <= b; i ++)
#define REP(i,a,b) for(ll i = a; i < b; i ++)
#define FORD(i,a,b) for(ll i = a; i >= b; i --)
#define FORS(i,a,b,c) for(ll i = a; i <= b; i += c)
#define FORDS(i,a,b,c) for(ll i = a; i >= b; i -= c)
#define FORA(x,a) for(auto x: a)
#define FORAA(l,r,a) for(auto [l, r]: a)

#define EL cerr << endl;
#define DEBUGN(a) cerr << a << endl;
#define DEBUGA(a, n) FOR (i, 1, n) cerr << a[i] << " "; cerr << endl;
#define DEBUG_AOP(a, n) FOR (i, 1, n) cerr << a[i].fi << " " << a[i].se << endl;  
#define DEBUG_A2D(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cerr << a[i][j] << " "; cerr << endl;}
#define DEBUG cerr << "shut the fuck up please :3" << endl;

#define YES cout << "YES\n"; return;
#define NO cout << "NO\n"; return;
 
template<class X, class Y> bool mimi(X &x, const Y &y) {if(x>y){x=y;return 1;}return 0;}
template<class X, class Y> bool mama(X &x, const Y &y) {if(x<y){x=y;return 1;}return 0;}
istream &operator >> (istream &st, Int &a) {string s;a=0;st>>s;bool g=1;REP(i,0,s.sz){if(i==0&&s[i]=='-'){g = 0;continue;}a=a*10+s[i]-'0';}if(!g)a=-a;return st;}
ostream &operator << (ostream &st, const Int &a) {Int t=a;if(t==0){st<<0;return st;}if(t<0){st<<'-';t=-t;}string b;while(t!=0){b.pb((t%10+'0'));t/=10;}reverse(all(b));st<<b;return st;}

const ll nom = 2;
const ll base[] = {577, 677, 877, 977};
const ll mod[] = {(ll)1e9 + 2277, (ll)1e9 + 5277, (ll)1e9 + 8277, (ll)1e9 + 9277};
const ii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

const ll INF = 1e18;
const ll N = 1e6 + 5;
const ll T = 4*N - 3;
const ll M = 1e9 + 7;

ll n;
ll a[N];
vi m[10][10][10][10];
bool m1[10], m2[10][10], m3[10][10][10];

void solve(ll testID) {
    cin >> n;
    FOR (i, 1, n) {
        cin >> a[i];
        m[a[i] % 10][a[i] / 10 % 10][a[i] / 100 % 10][a[i] / 1000].pb(i);
        m1[a[i] % 10] = true;
        m2[a[i] % 10][a[i] / 10 % 10] = true;
        m3[a[i] % 10][a[i] / 10 % 10][a[i] / 100 % 10] = true;
    }

    ll res = 0;
    FOR (i, 1, n) {
        FOR (j, i + 1, n) {
            vi a1, a2, a3, a4;
            if (a[i] % 10 == a[j] % 10) a1.pb(a[i] % 10);
            else {
                FOR (k, 1, 9)
                    if (k != a[i] % 10 && k != a[j] % 10)
                        a1.pb(k);
            } 
            
            if (a[i] / 10 % 10 == a[j] / 10 % 10) a2.pb(a[i] / 10 % 10);
            else {
                FOR (k, 1, 9)
                    if (k != a[i] / 10 % 10 && k != a[j] / 10 % 10)
                        a2.pb(k);
            } 

            if (a[i] / 100 % 10 == a[j] / 100 % 10) a3.pb(a[i] / 100 % 10);
            else {
                FOR (k, 1, 9)
                    if (k != a[i] / 100 % 10 && k != a[j] / 100 % 10)
                        a3.pb(k);
            } 

            if (a[i] / 1000 == a[j] / 1000) a4.pb(a[i] / 1000);
            else {
                FOR (k, 1, 9)
                    if (k != a[i] / 1000 && k != a[j] / 1000)
                        a4.pb(k);
            } 

            FORA (x, a1)
                if (m1[x]) 
                    FORA (y, a2)
                        if (m2[x][y])
                            FORA (z, a3)
                                if (m3[x][y][z]) 
                                    FORA (k, a4)
                                        FORA (v, m[x][y][z][k])
                                            if (v > j) {
                                                // cout << i << " " << j << " " << v << endl;
                                                res ++;
                                            }
        }
    }
    cout << res;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    int test = 1;
    // cin >> test;
    FOR (i, 1, test) solve(i);
}

詳細信息

Test #1:

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

input:

4
1234
2345
3456
4567

output:

4

result:

ok single line: '4'

Test #2:

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

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

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

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

input:

9
1234
2345
3456
4567
5678
6789
7891
8912
9123


output:

84

result:

ok single line: '84'

Test #6:

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

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

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: 0
Accepted
time: 3ms
memory: 3832kb

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:

43848

result:

ok single line: '43848'

Test #9:

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

input:

17
3433
3443
3444
3434
3333
3334
3343
3344
4333
4343
4334
4344
4433
4434
4444
4443
5678

output:

8

result:

ok single line: '8'

Test #10:

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

input:

21
1111
1113
1131
1133
1222
1312
1321
1323
1332
2122
2322
3112
3121
3123
3132
3222
3311
3313
3331
3333
4567

output:

28

result:

ok single line: '28'

Test #11:

score: 0
Accepted
time: 515ms
memory: 3860kb

input:

500
5225
6396
8284
5729
9576
3159
1831
9314
5674
4164
5166
5513
1765
8333
9921
7856
3789
6129
3882
1462
1322
5932
6859
1794
6426
8336
3265
2938
4487
7143
3653
4218
7814
3521
3349
5331
3486
7264
5385
8724
7421
5736
9875
9432
1588
5758
4319
9649
4224
6841
9639
1774
1551
9761
1944
3979
7682
5599
4289
7...

output:

5075198

result:

ok single line: '5075198'

Test #12:

score: 0
Accepted
time: 510ms
memory: 3876kb

input:

500
5114
6269
8111
5597
9326
2942
1773
8955
5577
4165
4969
5388
1691
8159
9766
7686
3789
5829
3855
1431
1283
5781
6655
1762
6292
8183
3156
2837
4417
6868
3591
4189
7629
3451
3241
5228
3414
6881
5367
8384
7166
5612
9755
9147
1526
5633
4239
9385
4191
6575
9345
1743
1447
9623
1884
3978
7438
5517
4231
7...

output:

5084517

result:

ok single line: '5084517'

Test #13:

score: -100
Time Limit Exceeded

input:

1000
5643
3673
9624
6633
5355
6586
9219
8148
9533
7777
2984
9365
5932
4617
5553
6716
2312
3599
2349
1216
9483
3558
3846
1353
3675
4621
7556
1842
9698
3958
2178
2595
7377
8579
1952
7632
1999
8277
3295
9384
7845
3467
5546
5266
5962
8118
8261
5395
2597
8256
7546
1343
1248
8936
1394
2478
9247
3392
9397
...

output:


result: