QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#785004 | #4955. Multidimensional Hangman | Yarema# | WA | 2ms | 4084kb | C++20 | 1.4kb | 2024-11-26 16:34:16 | 2024-11-26 16:34:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int P = 27;
const int N = 12;
LL pw[P];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
pw[0] = 1;
FOR(i, 1, N)
pw[i] = pw[i - 1] * P;
map<LL, int> cnt;
pair<int, string> ans = {1e9, ""};
int n, c;
cin >> n >> c;
vector<string> v(n);
FOR (i, 0, n)
cin >> v[i];
FOR (i, 0, n)
{
LL hs = 0;
FOR (j, 0, c)
{
if (v[i][j] != '*')
hs += (v[i][j] - 'a' + 1) * pw[j];
}
cnt[hs]++;
}
FOR (i, 0, n)
{
int pos = -1;
LL hs = 0;
FOR (j, 0, c)
{
if (v[i][j] == '*')
pos = j;
else
hs += (v[i][j] - 'a' + 1) * pw[j];
}
FOR (ch, 'a', 'z' + 1)
{
hs += (ch - 'a' + 1) * pw[pos];
v[i][pos] = ch;
int cur = 0;
FOR(j, 0, c)
{
hs -= (v[i][j] - 'a' + 1) * pw[j];
cur += cnt[hs];
hs += (v[i][j] - 'a' + 1) * pw[j];
}
ans = min(ans, MP(-cur, v[i]));
}
}
cout << ans.S << ' ' << -ans.F << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
input:
5 4 rat* ru*d rot* r*ta r*ta
output:
rata 3
result:
ok single line: 'rata 3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 4 bon* fon* n*no *eto *ano
output:
nano 2
result:
ok single line: 'nano 2'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 4084kb
input:
100 7 o*zzegh rkpu*gd bza*fkh oy*zegh *yzzegh yi*jvak *yzzegh oyzze*h oyzzeg* oyz*egh oyzze*h oyzzeg* o*zzegh wpryta* oyzzeg* oyz*egh o*zzegh nl*xbbs oyz*egh oy*zegh vfh*rjp o*zzegh tsnle*r oyzz*gh oyzz*gh *yzzegh o*zzegh oy*zegh oyzzeg* *ydjplh oy*zegh o*zzegh o*zzegh oyzze*h oyzz*gh oyzze*h ta*cud...
output:
eyzzegh 52
result:
wrong answer 1st lines differ - expected: 'oyzzegh 58', found: 'eyzzegh 52'