QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768221#5499. AliaseswxhtzdyWA 77ms5992kbC++201.5kb2024-11-21 02:58:212024-11-21 02:58:22

Judging History

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

  • [2024-11-21 02:58:22]
  • 评测
  • 测评结果:WA
  • 用时:77ms
  • 内存:5992kb
  • [2024-11-21 02:58:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<string> t(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i] >> t[i];
    }
    array<int, 3> res = {0, 0, 6};
    auto Update = [&](int a, int b, int c) {
      int x = res[0] + res[1] + res[2];
      int y = a + b + c;
      if (y < x) {
        res = {a, b, c};
      }
    };
    for (int a = 0; a <= 5; a++) {
      for (int b = 0; a + b <= 5; b++) {
        vector<pair<string, string>> v;
        for (int i = 0; i < n; i++) {
          string x = "";
          for (int j = 0; j < min(a, int(s[i].size())); j++) {
            x += s[i][j];
          }
          string y = "";
          for (int j = 0; j < min(b, int(t[i].size())); j++) {
            y += t[i][j];
          }
          v.push_back({x, y});
        }
        sort(v.begin(), v.end());
        int mx = 0;
        for (int i = 0; i < n; i++) {
          int ptr = i;
          while (ptr + 1 < n && v[ptr + 1] == v[i]) {
            ptr += 1;
          }
          mx = max(mx, ptr - i + 1);
          i = ptr;
        }
        mx -= 1;
        int d = 0;
        while (mx > 0) {
          mx /= 10;
          d += 1;
        }
        Update(a, b, d);
      }
    }
    cout << res[0] << " " << res[1] << " " << res[2] << '\n';
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3528kb

input:

1
11
sven eriksson
erik svensson
sven svensson
erik eriksson
bjorn eriksson
bjorn svensson
bjorn bjornsson
erik bjornsson
sven bjornsson
thor odinsson
odin thorsson

output:

0 0 2

result:

ok correct! (1 test case)

Test #2:

score: -100
Wrong Answer
time: 77ms
memory: 5992kb

input:

6
1
g u
14643
gj ek
hc bi
hi ke
ab ij
hk cj
ha bi
ag fe
eb ej
hd ei
bf gj
ke dd
ib jd
id jb
gd ei
cj bi
bi hg
ic dh
ke gk
af eg
fg dd
fe fa
be ge
hf kj
ih ci
gg jf
ed dd
eh gi
cc kd
ka fd
af gb
ka fe
ja ed
bc hi
eg cf
gg ff
kf gf
ii ch
hh ec
ei ec
cd gc
bh hb
dd id
ce bk
ib ic
bf kk
gh cd
hb he
if g...

output:

0 0 0
2 2 0
0 1 1
1 0 2
1 1 1
2 0 1

result:

wrong answer Loginy nie moga byc puste! (test case 1)