# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
385213 | ritul_kr_singh | PIN (CEOI10_pin) | C++17 | 7 ms | 2156 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
int mask;
bool comp(string x, string y){
for(int i=0; i<4; ++i){
if(((1<<i)&mask) and x[i]!=y[i]) return x[i]<y[i];
}
return false;
}
bool equal(string x, string y){
return comp(x, y)==comp(y, x);
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n, d, ans = 0; cin >> n >> d;
string a[n]; for(auto &i : a) cin >> i;
d = n-d;
for(mask=0; mask<16; ++mask){
int cnt = 0;
for(int i=0; i<4; ++i) if((1<<i)&mask) ++cnt;
if(cnt<d) continue;
sort(a, a+n, comp);
for(int i=0; i<n; ++i){
int j = i;
while(j+1<n and equal(a[i], a[j+1])) ++j;
ans += ((cnt-d)%2 ? -1 : 1) * ((j-i+1)*(j-i))/2;
i = j;
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |