#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("XMAS.INP");
ofstream fout("XMAS.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
//using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 9;
const int mxn = 50000 + 5, mxq = 2e5 + 5, sq = 500, mxv = 2e6 + 5;
const ll inf = 1e17 + 5;
//const int base= (1 << 18);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, d;
int to[mxn + 1], pw[4];
string s[mxn + 1];
int conv(string s){
int ans = 0;
for(int i = 0; i < sz(s); i++){
ans += to[s[i]] * pw[i];
}
return(ans);
}
namespace one{
ll cnt[mxv + 1];
void solve(){
ll res = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j < 4; j++){
char rev = s[i][j];
for(char c = '0'; c <= '9'; c++){
if(c != rev){
s[i][j] = c;
res += cnt[conv(s[i])];
s[i][j] = rev;
}
}
for(char c = 'a'; c <= 'z'; c++){
if(c != rev){
s[i][j] = c;
res += cnt[conv(s[i])];
s[i][j] = rev;
}
}
}
}
cout << res;
}
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> d;
pw[0] = 1;
for(int i = 0; i < 4; i++){
pw[i] = (pw[i - 1] * 36);
}
for(char c = '0'; c <= '9'; c++)to[c] = (c - '0');
for(char c = 'a'; c <= 'z'; c++)to[c] = (c - 'a') + 10;
for(int i = 1; i <= n; i++){
cin >> s[i];
}
if(d == 1){
one::solve();
}
return(0);
}
Compilation message
pin.cpp: In function 'int conv(std::string)':
pin.cpp:33:23: warning: array subscript has type 'char' [-Wchar-subscripts]
33 | ans += to[s[i]] * pw[i];
| ^
pin.cpp: In function 'int main()':
pin.cpp:70:40: warning: array subscript has type 'char' [-Wchar-subscripts]
70 | for(char c = '0'; c <= '9'; c++)to[c] = (c - '0');
| ^
pin.cpp:71:40: warning: array subscript has type 'char' [-Wchar-subscripts]
71 | for(char c = 'a'; c <= 'z'; c++)to[c] = (c - 'a') + 10;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
3168 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
3160 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
3164 KB |
Output isn't correct |
4 |
Incorrect |
48 ms |
3168 KB |
Output isn't correct |
5 |
Incorrect |
60 ms |
3164 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
3164 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
3164 KB |
Output isn't correct |
8 |
Incorrect |
65 ms |
3272 KB |
Output isn't correct |
9 |
Incorrect |
107 ms |
3164 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
3164 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
3164 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
3160 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
3164 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
3160 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
3164 KB |
Output isn't correct |
16 |
Incorrect |
79 ms |
3572 KB |
Output isn't correct |
17 |
Incorrect |
4 ms |
3160 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
3164 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
3164 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
3164 KB |
Output isn't correct |