# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867726 | Cookie | PIN (CEOI10_pin) | C++14 | 107 ms | 3572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |