QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783848 | #3574. Key Insight | SGColin# | 0 | 29ms | 4580kb | C++17 | 1.1kb | 2024-11-26 12:01:54 | 2024-11-26 12:01:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define eb emplace_back
#define pb push_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)
int d;
ll fac[101];
void work() {
set<int> s[d];
set<set<int>> S;
string A, B;
cin >> A >> B;
rep(i, 0, d - 1) rep(j, 0, d - 1) s[i].insert(j);
for (int i = 0; i < A.length(); i += d) {
rep(j, 0, d - 1) {
set<int> tmp;
rep(k, 0, d - 1)
if (A[i + j] == B[i + k]) {
if (s[j].find(k) == s[j].end()) continue;
tmp.insert(k);
}
swap(tmp, s[j]);
}
}
rep(i, 0, d - 1) S.insert(s[i]);
ll ans = 1;
for (auto &tmp : S) ans *= fac[tmp.size()];
printf("%lld\n", ans);
}
int main() {
fac[0] = 0;
fac[1] = 1;
rep(i, 2, 100) fac[i] = fac[i - 1] * i;
cin.tie(0);
ios::sync_with_stdio(false);
while (cin >> d) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 29ms
memory: 4580kb
input:
4 treewood ertedowo 1 nwerc ncrew 6 secret etrcse 1 impossibru youdontsay 1 a a 1 aa aa 2 aa aa 1 aaa aaa 3 aaa aaa 1 aaaa aaaa 2 aaaa aaaa 4 aaaa aaaa 1 aaaaa aaaaa 5 aaaaa aaaaa 1 aaaaaa aaaaaa 2 aaaaaa aaaaaa 3 aaaaaa aaaaaa 6 aaaaaa aaaaaa 1 aaaaaaa aaaaaaa 7 aaaaaaa aaaaaaa 1 aaaaaaaa aaaaaaaa ...
output:
1 0 2 0 1 1 2 1 6 1 2 24 1 120 1 2 6 720 1 5040 1 2 24 40320 1 6 362880 1 2 120 3628800 1 39916800 1 2 6 24 720 479001600 1 6227020800 1 2 5040 87178291200 1 6 120 1307674368000 1 2 24 40320 20922789888000 1 355687428096000 1 2 6 720 362880 6402373705728000 1 121645100408832000 0 0 1 2 1 0 576 576 1...
result:
wrong answer 71st lines differ - expected: '0', found: '576'