QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#250843#7687. Randias Permutation TaskLainRE 1ms3400kbC++231.1kb2023-11-13 19:36:262023-11-13 19:36:26

Judging History

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

  • [2023-11-13 19:36:26]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3400kb
  • [2023-11-13 19:36:26]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n, m;
  cin >> m >> n;
  vector<vi> a(n, vi(m));
  for (auto& x : a) for (auto& y : x) cin >> y, y--;
  reverse(a.begin(), a.end());
  set<vi> perms;
  if (n <= 20) {
    for (int mask = 1; mask < (1<<n); mask++) {
      vi p(m);
      iota(p.begin(), p.end(), 0);
      rep(b, 0, n) {
        if (mask>>b&1) {
          vi q(m);
          rep(i, 0, m)
            q[i] = a[b][p[i]];
          p = std::move(q);
        }
      }
      // Insert q in some set and test??
      perms.insert(p);
    }
  } else {
    rep(i, 0, n) {
      set<vi> created_set;
      for (auto& perm : perms) {
        vi res(m);
        rep(j, 0, m)
          res[i] = a[i][perm[i]];
        created_set.insert(res);
      }
      perms.merge(created_set);
      perms.insert(a[i]);
    }
  }
  cout << perms.size() << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 4
1 2 3 4 5
5 1 3 4 2
3 4 1 5 2
5 2 4 1 3

output:

8

result:

ok 1 number(s): "8"

Test #2:

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

input:

2 1
2 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Runtime Error

input:

1 180
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:


result: