Submission #867726

#TimeUsernameProblemLanguageResultExecution timeMemory
867726CookiePIN (CEOI10_pin)C++14
0 / 100
107 ms3572 KiB
#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 (stderr)

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;
      |                                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...