QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#208078#1361. Ant TypingrlongWA 36ms3860kbC++141004b2023-10-09 05:35:012023-10-09 05:35:02

Judging History

This is the latest submission verdict.

  • [2023-10-09 05:35:02]
  • Judged
  • Verdict: WA
  • Time: 36ms
  • Memory: 3860kb
  • [2023-10-09 05:35:01]
  • Submitted

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] = 1;
        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+1 << endl;
    
    
    

}

详细

Test #1:

score: 100
Accepted
time: 33ms
memory: 3664kb

input:

6

output:

1

result:

ok single line: '1'

Test #2:

score: -100
Wrong Answer
time: 36ms
memory: 3860kb

input:

352836512461179399826927828445163785261417666171453483576899676763764928341261962358737253818463814858565221466575498899898835568743316628247174676952381449147193191788177911797527361649543158616436321694172452689147288835568666918784929695569394655833978219612584637258492511247969998253315177569943...

output:

100000

result:

wrong answer 1st lines differ - expected: '392933', found: '100000'