제출 #1322934

#제출 시각아이디문제언어결과실행 시간메모리
1322934yerkoshPIN (CEOI10_pin)C++20
5 / 100
1096 ms11776 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define inf 1e18+1e9 #define F first #define S second #define int long long #define mod (int)(1e9+7) #define maxn 1000100 #define pii pair<int,int> #define mod2 998244353 const int maxtime=1e8; const long double eps=1e-9; ld dist(ld x1,ld y1,ld x2,ld y2) { return sqrt(abs(x1-x2)*abs(x1-x2)+abs(y1-y2)*abs(y1-y2)); } int n,d; string s[50500]; int b[10]; void solve () { cin>>n>>d; for (int i=1;i<=n;i++) { cin>>s[i]; } map<string,int>mp1,mp2,mp3,mp4; int ans=0; for (int i=1;i<=n;i++) { ans+=mp1[s[i].substr(1)]; mp1[s[i].substr(1)]++; ans+=mp2[s[i].substr(0,3)]; mp2[s[i].substr(0,3)]++; string t=s[i].substr(1,1); t+=s[i].substr(2,2); ans+=mp3[t]; mp3[t]++; t=s[i].substr(1,2); t+=s[i].substr(3,1); ans+=mp4[t]; mp4[t]++; } if (d==1) { cout<<ans; return; } if (d==2) { ans=-ans; map<string,int>mp[7]; for (int i=1;i<=n;i++) { string t[7]; t[1]=s[i][0]+s[i][1]; t[2]=s[i][0]+s[i][2]; t[3]=s[i][0]+s[i][3]; t[4]=s[i][1]+s[i][2]; t[5]=s[i][1]+s[i][3]; t[6]=s[i][2]+s[i][3]; for (int j=1;j<=6;j++) { ans+=mp[j][t[j]]; mp[j][t[j]]++; } } cout<<ans; return; } for (int i=1;i<=n;i++) { for (int j=i+1;j<=n;j++) { int cnt=0; for (int k=0;k<4;k++) { if (s[i][k]!=s[j][k])cnt++; } b[cnt]++; } } cout<<b[d]; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int t=1; // cin>>t; for (int ii=1;ii<=t;ii++) { solve(); // asd(); if (ii<t)cout<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...