# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
480233 | mohamedsobhi777 | PIN (CEOI10_pin) | C++14 | 219 ms | 17928 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, d;
long long ans ;
string st[N] ;
map<long long,long long> atm[17] ;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
cin >> n >> d ;
d = 4 - d;
for(int i = 0 ;i < n; ++ i){
cin >> st[i] ;
}
vector<int> masks ;
for(int i = 0;i < 16 ;++ i){
masks.push_back(i) ;
}
sort(masks.begin(), masks.end(), [&](int x, int y){
return __builtin_popcount(x) > __builtin_popcount(y) ;
}) ;
for(int i = 0 ;i < n; ++ i ){
long long ret = 0 ;
vector<long long> dp(18, 0) ;
for(auto u : masks){
int hsh = 0 ;
for(int k = 0 ; k < 4 ; ++ k){
if(u&(1<<k)){
hsh = hsh * 150 + st[i][k] ;
}
}
dp[u] += atm[u][hsh]++ ;
for(int sub = u ; sub ; sub = (sub - 1) & u){
if(u != sub)
dp[sub] -= dp[u] ;
}
}
for(auto u : masks){
if(__builtin_popcount(u) == d){
ret += dp[u] ;
}
}
ans += ret ;
}
cout << ans ;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |