QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#335600#7882. Linguistics Puzzleucup-team093WA 2ms3680kbC++201.5kb2024-02-23 16:40:472024-02-23 16:40:50

Judging History

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

  • [2024-02-23 16:40:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3680kb
  • [2024-02-23 16:40:47]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using LL = long long;

const int MAXN = 52 + 3;

struct Node{
  int first, second, third, id;
  bool operator< (Node j) const {
    if(first == j.first){
      if(second == j.second){
        if(third == j.third) return id < j.id;
        return third < j.third;
      }
      return second < j.second;
    }
    return first < j.first;
  }
}cnt[500], _cnt[500];

string s;
int n;
vector<int> mp[MAXN];
multiset<Node> st;

int COL(char ch){ return ('a' <= ch && ch <= 'z' ? ch - 'a' : ch - 'A' + 26); }
char CH(int i){ return (0 <= i && i < 26 ? 'a' + i : 'A' + i - 26); }

void work(){
  cin >> n;
  for(int i = 0; i < n; i++) cnt[i] = {0, 0, 0, i}, _cnt[i] = {0, 0, 0, -1};
  st.clear();
  for(int i = 1; i <= n * n; i++){
    cin >> s;
    if(s.size() == 2){
      cnt[COL(s[0])].second++, cnt[COL(s[1])].third++;
    }else{
      cnt[COL(s[0])].first++;
    }
  }
  for(int i = 0; i < n; i++) st.insert(cnt[i]);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      int x = i * j;
      if(x < n) _cnt[x].first++;
      else _cnt[x / n].second++, _cnt[x % n].third++;
    }
  }
  for(int i = 0; i < n; i++){
    auto it = st.lower_bound(_cnt[i]);
    cout << CH(Node(*it).id);
    st.erase(it);
  }
  cout << "\n";
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while(T--) work();
  return 0;
}
/*
0 0 0 0
0 1 2 3
0 2 4 6
0 3 6 9

7 d
1 c
2 a
2 b

cd cb cb bc

3 c
1 b

1 c
2 b
1 d
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

2
3
a b a b b b b c cc
4
d d d d d c b a d b cd cb d a cb bc

output:

bca
dcba

result:

ok OK

Test #2:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

2
4
d a a bc ba bc b a a a d a a cb c c
4
a b da b b d ad b db b a c da b c b

output:

abcd
bdac

result:

ok OK

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3680kb

input:

50
3
b b b a a c b b cc
4
d ab c ad d b ba ab c b d d d d d a
5
a aa aa ab ab ae b b e c c c ba c c c c dd d d dd c e c e
6
a ca a a a a a a ce a a b ba ba bc bc bd be e c c ca a cd cd be d d dc dc e e a eb f f
7
a a a a a a a a cf a a a a b b b b c c c cf a dd d dc d dd e f ed ee ee fb eg eg eg eg ...

output:

bca
dabc
cadbe
abcdef
aefdcgb
fcheabgd
bhgfedcia
jhcgfideba
fjbadkegcih
klhgjbaedcif
igkjmclfedhba
nflijahgmbdcek
anmlfijbgkhdceo
nofmlkjchdbegipa
aponblgjihcfqdkme
iqmonhckfrpgjedlba
prisodmbkjqghfencla
tcrdpoaklmjihfgeqsbn
utiraponmlksghjfecdbq
qotsrvjunmlkpiegfhdcba
pvutsrhwoimlkjnqgfedbca
xbvuts...

result:

wrong answer The product 7*7=49 is not in the output at case #28