Submission #645866

# Submission time Handle Problem Language Result Execution time Memory
645866 2022-09-28T08:18:44 Z TimDee NoM (RMI21_nom) C++17
0 / 100
500 ms 255952 KB
#include <bits/stdc++.h>
using namespace std;

#define forn(i,n) for (int i=0; i<n; ++i)

vector<vector<int>>v;
void bf(vector<int>&vis, int n, vector<int>&s) {
	if (s.size()>=n) {
		v.push_back(s);
		return;
	}
	for (int i=1; i<=n; ++i) {
		if (vis[i]) continue;
		vis[i]=1;
		s.push_back(i);
		bf(vis,n,s);
		vis[i]=0;
		s.pop_back();
	}
}

void solve() {
	int n,m; cin>>n>>m;
	if (n>5) return;
	vector<int>vis(2*n+1,0);
	vector<int>s;
	bf(vis,2*n,s);
	int ans=0;
	for (auto a:v) {
		int paiu=1;
		forn(i,2*n) {
			for (int k=i%m; k<2*n; k+=m) {
				if (k==i) continue;
				if (abs(a[k]-a[i])==n) paiu=0;
			}
		}
		ans+=paiu;
	}
	cout<<ans;
}

int32_t main() {
	solve();
	return 0;
}

Compilation message

Main.cpp: In function 'void bf(std::vector<int>&, int, std::vector<int>&)':
Main.cpp:8:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |  if (s.size()>=n) {
      |      ~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 9 ms 3340 KB Output is correct
8 Correct 8 ms 3284 KB Output is correct
9 Execution timed out 1053 ms 255952 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 9 ms 3340 KB Output is correct
8 Correct 8 ms 3284 KB Output is correct
9 Execution timed out 1053 ms 255952 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 9 ms 3340 KB Output is correct
8 Correct 8 ms 3284 KB Output is correct
9 Execution timed out 1053 ms 255952 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 9 ms 3340 KB Output is correct
8 Correct 8 ms 3284 KB Output is correct
9 Execution timed out 1053 ms 255952 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 9 ms 3340 KB Output is correct
8 Correct 8 ms 3284 KB Output is correct
9 Execution timed out 1053 ms 255952 KB Time limit exceeded
10 Halted 0 ms 0 KB -