QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#238448#7687. Randias Permutation Taskucup-team2303#WA 3ms12296kbC++141.7kb2023-11-04 16:45:522023-11-04 16:45:52

Judging History

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

  • [2023-11-04 16:45:52]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:12296kb
  • [2023-11-04 16:45:52]
  • 提交

answer

/*
60 + 0 + 100 + 64 = 224.
*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
#define pb push_back
#define pii pair<int, int>
inline int read()
{
	int sum = 0, nega = 1;
	char ch = getchar();
	while (ch > '9'||ch < '0')
	{
	    if (ch == '-') nega = -1;
		ch = getchar();
	}
	while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
	return sum * nega;
}
const int N = 189, mod = 1e9 + 7;
inline void add(int &x, int y) {x = (x + y) % mod;}
inline void del(int &x, int y) {x = (x - y + mod) % mod;}
int n, m, a[N][N], ans, p[N], tmp[N];
vector<int> r;
map<vector<int>, int> mp;
inline void solve1()
{
	L(i, 1, (1 << n) - 1)
	{
		L(j, 1, m) p[j] = j;
		L(j, 0, n - 1)
			if(i & (1 << j))
			{
				L(k, 1, m) tmp[k] = p[a[j + 1][k]];
				L(k, 1, m) p[k] = tmp[k];
			}
		r.clear();
		L(j, 1, m) r.pb(p[j]);
		if(!mp[r]) mp[r] = 1, ans++;
	}
	cout << ans % mod << endl; return ;
}
vector<int> G[362889];
bool fl = 0;
inline void trans(vector<int> x, int k)
{
	L(i, 1, m) p[i] = x[i - 1];
	L(i, 1, m) tmp[i] = p[a[k + 1][i]]; r.clear();
	L(i, 1, m) r.pb(tmp[i]);
	if(!mp[r]) mp[r] = 1, ans++; bool ee = 0;
	L(i, 1, m)
		if(tmp[i] != i) ee = 1;
	if(!ee && !fl) fl = 1, ans++; return ;
}
inline void solve2()
{
	r.clear();
	L(i, 1, m) r.pb(i); mp[r] = 1;
	L(i, 1, n)
	{
  		int cnt = 0;
		for (auto v : mp) G[++cnt] = v.first;
		L(j, 1, cnt) trans(G[j], i);
	}
	cout << ans % mod << endl; return ;
}
signed main()
{
	m = read(), n = read();
	L(i, 1, n)
		L(j, 1, m) a[i][j] = read();
	if(n <= 18) solve1();
	else solve2();
	return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 12104kb

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

input:

2 1
2 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 12296kb

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:

2

result:

wrong answer 1st numbers differ - expected: '1', found: '2'