QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#77273#5501. Ctrl+C Ctrl+VnweeksWA 0ms3340kbC++171.5kb2023-02-13 21:16:212023-02-13 21:19:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-13 21:19:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3340kb
  • [2023-02-13 21:16:21]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

string to_string(string s) { return s; }
template <typename T> string to_string(T v) {
  bool first = true;
  string res = "[";
  for (const auto &x : v) {
    if (!first)
      res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "]";
  return res;
}

void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cout << ' ' << to_string(H);
  dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

void solve() {
  int N;
  cin >> N;
  vector<pair<string, string>> names(N);
  for (auto &[s, t] : names)
    cin >> s >> t;

  int solA = 1e18, solB = 1e18, solC = 1e18;

  for (int a = 0; a <= 6; ++a)
    for (int b = 0; b <= 6 - a; ++b) {
      map<string, int> cnt;

      for (auto &[s, t] : names) {
        cnt[s.substr(0, a) + t.substr(0, b)]++;
      }
      int c = a + b == 0;
      int maxAllowed = c == 0 ? 1 : 10;
      for (auto &[s, x] : cnt) {
        while (maxAllowed < x)
          c++, maxAllowed *= 10;
      }
      if (solA + solB + solC > a + b + c)
        solA = a, solB = b, solC = c;
    }
  cout << solA << ' ' << solB << ' ' << solC << '\n';
}

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int nbTests;
  cin >> nbTests;
  for (int iTest(0); iTest < nbTests; ++iTest)
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3340kb

input:

3
aniasieurodzilaapotemnicsieniedzialo
nicciekawegouanianiagnieszkianialicji
jeszczekrotszaautobiografiaani

output:

0 0 1
0 0 1
0 0 1

result:

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