QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#208076 | #1361. Ant Typing | rlong | WA | 35ms | 3532kb | C++14 | 1002b | 2023-10-09 05:33:19 | 2023-10-09 05:33:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string str;
map<char, int> mp;
int cnts[12][12];
int cost[12][12];
set<int> s;
int curp[12];
long long best = 99999999999999999LL;
int main() {
cin >> str;
mp['1'] = 1;
mp['2'] = 2;
mp['3'] = 3;
mp['4'] = 4;
mp['5'] = 5;
mp['6'] = 6;
mp['7'] = 7;
mp['8'] = 8;
mp['9'] = 9;
for(int i=0;i<str.length()-1;i++) {
cnts[ mp[str[i]] ][ mp[str[i+1]] ]++;
}
int perm[] = {0,1,2,3,4,5,6,7,8,9};
ll best = 99999999999999999LL;
do {
ll cur = 0;
for(int i=1;i<=9;i++) cost[i][i] = 0;
for(int i=1;i<=9;i++) {
for(int j=1;j<=9;j++) {
cur += cnts[perm[i]][perm[j]] += max(j-i,i-j) * cost[perm[i]][perm[j]];
}
}
best = min(best, cur);
} while(next_permutation(perm+1,perm+1+9));
cout << best << endl;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 35ms
memory: 3532kb
input:
6
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'