QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#784053#3574. Key InsightSGColin#Compile Error//Python31.3kb2024-11-26 12:57:402024-11-26 12:57:40

Judging History

This is the latest submission verdict.

  • [2024-11-26 12:57:40]
  • Judged
  • [2024-11-26 12:57:40]
  • Submitted

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];
    map<set<int>, 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[s[i]];
    ll ans = 1;
    int sum = 0;
    for (auto &[tmp, num] : S) {
        if (tmp.size() != num) {puts("0"); return;}
        ans *= fac[tmp.size()];
        sum += tmp.size();
    }
    if (sum != d) puts("0");
    else 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;
}

详细

  File "answer.code", line 2
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax