Submission #1322970

#TimeUsernameProblemLanguageResultExecution timeMemory
1322970baqbergenPIN (CEOI10_pin)C++20
0 / 100
65 ms67684 KiB
#include <bits/stdc++.h>
#define al long long
#define pb push_back
#define f first
#define s second
#define ap cout
#define ak "\n"
#define all(x) x.begin(),x.end()
#define ok  cout << __LINE__ << "| "<< "----------OK--------- -----" << endl;
#define deb(x) cout << __LINE__ << "| "<< #x  << " = " << x<< endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define af(x) ap<<x;
#define ai(x) af((x ? out[1] : out[0]))
#define cin(n,b) for(al i=1;i<=n;i++)cin>>b[i];
using namespace std;
const al nn=2e6+9;
const string out[2]={"NO","YES"};
al n,d,res,ind;
string s[nn];
set<string>a[20];
set<string>cur;
void tp(){
	cin>>n>>d;
	for(al i=1;i<=n;i++){
		string p;
		cin>>p;
		cur.insert(p);
	}
	for(auto j:cur){
		s[++ind]=j;
	}
	if(ind==1){
		af(0);
		return;
	}
	if(d==1){
		for(al i=1;i<=ind;i++){
			for(al j=1;j<=4;j++){
				string t;
				for(al k=1;k<=4;k++){
					if(j==k)continue;
					t+=s[i][k];
				}
				a[j].insert(t);
			}
		}
		for(al i=1;i<=n;i++){
			res+=4-a[i].size();
		}
		af(res);
	}
}
signed main(){
    fast;
    al tt=1;
    //cin>>tt;
    while(tt--){
        tp();
        ap<<ak;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...