QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617315 | #1965. Trio | IllusionaryDominance# | TL | 893ms | 3868kb | C++20 | 1.8kb | 2024-10-06 14:53:29 | 2024-10-06 14:53:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
int b[10005];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n); for(auto &x : a) cin >> x;
vector<int> D({1, 10, 100, 1000});
auto upd = [&](int x, int v)
{
for(int i=0; i<10000; ++i)
{
bool flg = 1;
for(int j=0; j<4; ++j) flg &= (((i/D[j])%10) == ((x/D[j])%10) || ((i/D[j])%10) == 0) ;
b[i]+=v*flg;
}
};
long long ans = 0;
for(int i=2; i<n; ++i) upd(a[i], 1);
for(int j=1; j<n-1; ++j, upd(a[j], -1))
{
for(int i=0; i<j; ++i)
{
int x=a[i], y=a[j];
vector<vector<int>> v(4);
int msk = 0, MSK = 0;
for(int k=0; k<4; ++k)
{
msk |= ((x/D[k])%10==(y/D[k])%10)<<k;
v[k].push_back((x/D[k])%10);
if(!(msk>>k&1)) v[k].push_back((y/D[k])%10);
}
// cerr << a[i] << " " << a[j] << "====\n";
int tot = 0;
for(int k=0; k<16; ++k) if((msk & k) == msk)
{
int kk = __popcount(k);
int cnt = 0;
function<void(int,int)> dfs = [&](int tmp, int i) -> void
{
if(b[tmp]==0) return ;
if(i == 4) { cnt += b[tmp]; return ;}
if(k>>i&1) for(auto vv : v[i]) dfs(tmp+D[i]*vv, i+1);
else dfs(tmp, i+1);
};
dfs(0, 0);
tot += ((kk&1)?1:(-1))*cnt;
}
ans += abs(tot);
}
}
cout << ans << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
input:
4 1234 2345 3456 4567
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 3ms
memory: 3640kb
input:
9 1299 2399 3499 4599 5699 6799 7899 8999 9199
output:
84
result:
ok single line: '84'
Test #3:
score: 0
Accepted
time: 3ms
memory: 3868kb
input:
9 1239 2349 3459 4569 5679 6789 7899 8919 9129
output:
84
result:
ok single line: '84'
Test #4:
score: 0
Accepted
time: 3ms
memory: 3860kb
input:
9 1999 2999 3999 4999 5999 6999 7999 8999 9999
output:
84
result:
ok single line: '84'
Test #5:
score: 0
Accepted
time: 3ms
memory: 3636kb
input:
9 1234 2345 3456 4567 5678 6789 7891 8912 9123
output:
84
result:
ok single line: '84'
Test #6:
score: 0
Accepted
time: 6ms
memory: 3652kb
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: 5ms
memory: 3640kb
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: 28ms
memory: 3572kb
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: 5ms
memory: 3656kb
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: 7ms
memory: 3584kb
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: 298ms
memory: 3660kb
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: 296ms
memory: 3520kb
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: 0
Accepted
time: 883ms
memory: 3796kb
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:
40686935
result:
ok single line: '40686935'
Test #14:
score: 0
Accepted
time: 893ms
memory: 3644kb
input:
1000 5659 3899 9639 6658 5344 6624 9339 8138 9619 7818 3314 9459 5967 4695 5557 6692 2422 3792 2451 1228 9568 3755 4149 1383 3915 4696 7571 1875 9687 4223 2324 2669 7413 8624 2158 7668 2244 8275 3467 9487 7874 3624 5555 5258 5982 8114 8255 5376 2674 8242 7558 1382 1254 9152 1443 2535 9355 3556 9489 ...
output:
40589947
result:
ok single line: '40589947'
Test #15:
score: 0
Accepted
time: 885ms
memory: 3588kb
input:
1000 5565 3799 9621 6574 5284 6539 9171 8136 9555 7837 3234 9315 5885 4634 5482 6647 2465 3686 2491 1242 9468 3622 3897 1433 3816 4637 7538 2117 9689 3972 2415 2664 7381 8532 2235 7657 2317 8247 3414 9349 7865 3495 5481 5196 5899 8128 8217 5322 2678 8194 7533 1425 1279 8812 1485 2551 9188 3457 9351 ...
output:
40686926
result:
ok single line: '40686926'
Test #16:
score: -100
Time Limit Exceeded
input:
2000 5699 2343 5288 9952 3128 8562 7628 4456 8712 4359 8217 8242 3426 2742 7267 9136 9277 6815 1671 1181 9432 9411 7289 5719 2345 6542 4235 8919 8122 9981 1622 1782 4164 4668 1537 4267 1562 4532 6391 7882 4371 2196 8633 6411 6452 6991 6275 8334 8679 6972 7141 9822 1191 4845 7199 8737 8495 7826 7456 ...