QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#644092#7687. Randias Permutation Taskucup-team2526TL 0ms3624kbC++201.7kb2024-10-16 10:50:472024-10-16 10:50:47

Judging History

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

  • [2024-10-16 10:50:47]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3624kb
  • [2024-10-16 10:50:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)

void err() {
	std::cout << std::endl;
}

template<class T, class... Ts>
void err(T arg, Ts &... args) {
	std::cout << fixed << setprecision(10) << arg << ' ';
	err(args...);
}

void GENSHEN_START() {
	int n,m;cin >> n >> m;
	vector c(m + 5,vector<int>(n + 5));
	for (int i = 1;i <= m;i++) {
		for (int j = 0;j < n;j++) cin >> c[i][j];
	}
	if (n <= 9) {
		set<vector<int>>s;	
		vector<int>a;				
		vector<int>b;
		set<vector<int>>s1;
		for (int i = 1;i <= m;i++) {
			a.clear();		
			for (int j = 0;j < n;j++) {
				a.push_back(c[i][j]);
			}
			if (s.empty()) s.insert(a);
			else {
				b.clear();
				s1.clear();
				for (auto j : s) {
					for (int k = 0;k < n;k++) {
						b.push_back(j[a[k] - 1]);
					}
					if (!s.count(b)) s1.insert(b);
				}
				s.insert(a);
				for (auto j : s1) s.insert(j);
			}
		}
		cout << s.size() << '\n';
		return ;
	}
	if (m <= 20) {
		set<vector<int>>s;
		for (int i = 1;i < (1ll << m);i++) {
			vector<int>a;
			for (int j = 0;j < m;j++) {
				if ((i >> j) & 1) {
					if (a.empty()) {
						for (int k = 0;k < n;k++) {
							a.push_back(c[j + 1][k]);
						}
					}
					else {
						vector<int>b;
						for (int k = 0;k < n;k++) {
							b.push_back(a[c[j + 1][k] - 1]);
						}
						for (int k = 0;k < n;k++) a[k] = b[k];
					}
				}
			}
			s.insert(a);
		}
		cout << s.size() << '\n';
		return ;
	}
}

signed main()
{
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int T = 1;
	//cin >> T;
	while (T--) GENSHEN_START();
	return 0;
}

詳細信息

Test #1:

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

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: 3620kb

input:

2 1
2 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

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:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

180 1
52 71 167 89 165 102 119 125 9 128 180 24 48 172 108 22 164 28 159 111 30 91 67 51 136 97 126 133 177 65 115 157 114 11 171 178 23 127 163 103 99 18 56 94 176 77 44 1 124 74 61 87 4 40 63 92 169 84 146 6 88 55 152 49 10 90 43 174 70 50 69 154 73 147 110 20 82 59 112 12 64 143 16 138 5 170 155 ...

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: -100
Time Limit Exceeded

input:

2 90
1 2
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
2 1
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
1 2
1 2
1 2
2 1
1 2
2 1
1 2
1 2
1 2
2 1
2 1
1 2
2 1
1 2
2 1
1 2
1 2
2 1
1 2
2 1
2 1
2 1
2 1
1 2
2 1
2 1
2 1
2 1
1 2
1 2
2 1
2 1
1 2
1 2
1 2
2 1
1 2
2 1
2 1
1 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
1 2
1 2
1 2
2 1
1 2
1 2
2 1
1 2
1 2...

output:


result: