QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#244375#7687. Randias Permutation TaskzhouchenfengWA 0ms3632kbC++141.3kb2023-11-09 00:08:492023-11-09 00:08:49

Judging History

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

  • [2023-11-09 00:08:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2023-11-09 00:08:49]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long

const int mod = 1e9 + 7;

void solve(){
	int n,m;
	cin >> n >> m;
	int a[m + 1][n + 1];
	for (int i = 1;i <= m;i ++){
		for (int j = 1;j <= n;j ++)
			cin >> a[i][j];
	}
	
	bool f = 0;
	bool vis[n];
	for (int i = 1;i <= m;i ++){
		vis[i] = 1;
		for (int j = 1;j <= n;j ++)
			if (a[i][j] != j){
				vis[i] = 0;
				break;
			}
		if (vis[i]) f = 1;
	}
	
	int dp[m + 1] = {};
	int ans = 0;
	
	if (f) ans ++;
		
	for (int i = 1;i <= m;i ++){
		if (vis[i]) continue;
		
		int p = i;
		while(-- p){
			if (vis[p]) continue;
			bool che = 1;
			for (int j = 1;j <= n;j ++)
				if (a[i][j] != a[p][j]) che = 0;
			if (che) break;
		}
		//cout << i << " " << p << "*** \n";
		if (p == 0){
			dp[i] ++;
			p ++;
		}
		
		for (int j = p ;j < i;j ++){
			if (vis[j]) continue;
			bool check = 1;
			for (int pos = 1;pos <= n;pos ++)
				if (a[i][a[j][pos]] != pos){
					check = 0;
					break;
				}
			if (!check) dp[i] = (dp[i] + dp[j]) % mod;
			if (check && !f){
				f = 1;
				ans ++;
			}
		}
		//cout << i << " " << dp[i] << "\n";
		ans = (ans + dp[i]) % mod;
	}
	cout <<	ans << "\n";
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	t = 1 ;
	while(t --){
		solve();
	}
}

詳細信息

Test #1:

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

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

input:

2 1
2 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

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

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: 0
Accepted
time: 0ms
memory: 3620kb

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:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

90 2
43 44 28 69 66 18 5 23 87 8 24 89 31 29 81 1 68 2 78 53 49 54 4 13 77 61 33 57 63 85 55 79 46 35 45 64 65 42 30 6 19 74 82 80 17 26 32 59 7 72 16 3 47 73 39 36 25 34 56 86 71 62 84 40 41 11 50 27 20 14 37 12 38 58 48 83 76 70 51 88 22 90 21 9 10 60 15 52 75 67
9 73 52 51 81 16 71 77 6 57 11 75 ...

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3632kb

input:

3 60
2 1 3
3 1 2
3 2 1
1 2 3
1 2 3
3 2 1
3 1 2
2 3 1
2 1 3
3 1 2
2 3 1
2 3 1
2 1 3
3 2 1
3 1 2
3 2 1
1 2 3
2 1 3
2 1 3
2 1 3
2 3 1
2 3 1
2 3 1
3 1 2
1 2 3
3 1 2
2 3 1
2 3 1
2 1 3
1 2 3
3 1 2
2 1 3
2 3 1
2 3 1
2 3 1
3 1 2
2 3 1
1 2 3
1 2 3
3 2 1
3 1 2
3 1 2
2 3 1
1 3 2
3 1 2
1 3 2
1 2 3
1 3 2
1 3 2
3...

output:

220864248

result:

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