QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#275906 | #7882. Linguistics Puzzle | SGColin# | WA | 5ms | 3960kb | C++20 | 1.4kb | 2023-12-05 11:15:10 | 2023-12-05 11:15:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tii;
inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
inline void work() {
int n = rd();
vector<int> cnt1(n, 0), cnt2(n, 0);
rep(i, 0, n - 1) rep(j, 0, n - 1) {
int w = i * j;
++cnt2[w % n];
w = w / n;
if (w) ++cnt1[w];
}
map<pii, vector<int>> f;
rep(i, 0, n - 1) f[{cnt1[i], cnt2[i]}].push_back(i);
map<char, int> c1, c2;
set<char> ch;
char s[20];
rep(i, 1, n * n) {
scanf("%s", s + 1);
int l = strlen(s + 1);
if (l == 1) {++c2[s[1]]; ch.insert(s[1]);}
else {
++c1[s[1]]; ch.insert(s[1]);
++c2[s[2]]; ch.insert(s[2]);
}
}
vector<char> ans(n);
for (auto x : ch) {
pii c = make_pair(c1[x], c2[x]);
ans[f[c].back()] = x; f[c].pop_back();
}
rep(i, 0, n - 1) putchar(ans[i]); puts("");
}
int main() {
per(t, rd(), 1) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3960kb
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: 5ms
memory: 3668kb
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 pvutsrhwoimlnjkqgfedbca xbvuts...
result:
wrong answer The product 3*20=60 is not in the output at case #21