# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
336743 | 2020-12-16T16:39:41 Z | nandonathaniel | PIN (CEOI10_pin) | C++14 | 615 ms | 14852 KB |
#include<bits/stdc++.h> using namespace std; map<string,int> mp[16]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); long long ans=0; string s; int n,d; cin >> n >> d; for(int it=1;it<=n;it++){ cin >> s; for(int mask=0;mask<(1<<4);mask++){ if(__builtin_popcount(mask)!=d)continue; string t=""; vector<int> v; bool ya[4]; memset(ya,false,sizeof(ya)); for(int i=0;i<4;i++){ if((1<<i) & mask)v.push_back(i); else{ t+=s[i]; ya[i]=true; } } ans+=mp[15-mask][t]; for(int i=1;i<(1<<v.size());i++){ for(int j=0;j<v.size();j++)ya[v[j]]=true; int msk=0; string k=""; for(int j=0;j<4;j++){ if(ya[j]){ msk+=(1<<j); k+=s[j]; } } if(__builtin_popcount(i)&1)ans-=mp[msk][k]; else ans+=mp[msk][k]; for(int j=0;j<v.size();j++)ya[v[j]]=false; } } for(int mask=0;mask<(1<<4);mask++){ string t=""; for(int i=0;i<4;i++){ if((1<<i) & mask)t+=s[i]; } mp[mask][t]++; } } cout << ans << '\n'; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1004 KB | Output is correct |
2 | Incorrect | 13 ms | 1004 KB | Output isn't correct |
3 | Incorrect | 8 ms | 876 KB | Output isn't correct |
4 | Correct | 111 ms | 3436 KB | Output is correct |
5 | Correct | 146 ms | 3820 KB | Output is correct |
6 | Incorrect | 222 ms | 3744 KB | Output isn't correct |
7 | Incorrect | 174 ms | 3436 KB | Output isn't correct |
8 | Correct | 157 ms | 4076 KB | Output is correct |
9 | Correct | 260 ms | 5484 KB | Output is correct |
10 | Incorrect | 455 ms | 5868 KB | Output isn't correct |
11 | Incorrect | 235 ms | 3948 KB | Output isn't correct |
12 | Incorrect | 480 ms | 5728 KB | Output isn't correct |
13 | Incorrect | 303 ms | 4204 KB | Output isn't correct |
14 | Incorrect | 191 ms | 3948 KB | Output isn't correct |
15 | Incorrect | 358 ms | 5740 KB | Output isn't correct |
16 | Correct | 283 ms | 11244 KB | Output is correct |
17 | Incorrect | 615 ms | 14828 KB | Output isn't correct |
18 | Incorrect | 377 ms | 12268 KB | Output isn't correct |
19 | Incorrect | 453 ms | 13804 KB | Output isn't correct |
20 | Incorrect | 523 ms | 14852 KB | Output isn't correct |