Submission #857076

#TimeUsernameProblemLanguageResultExecution timeMemory
857076iulia_morariuNoM (RMI21_nom)C++17
9 / 100
1050 ms432 KiB
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0);ios::sync_with_stdio(0); //1. int n, m; //2. cin >> n >> m; vector < pair<int, int> > v(2 * n); //3. for(int i = 0; i < n; i++){ v[i].first = i + 1; v[i].second = 1; } for(int i = 0; i < n; i++){ v[i + n].first = i + 1; v[i + n].second = 2; } sort(v.begin(), v.end()); long long int f = 1; for(int i = 1; i <= n * 2; i++) f *= i; int p[n + 1]; long long int cnt = 0; for(int i = 0; i < f; i++){ bool ok = 1; for(int j = 0; j < n; j++) p[j + 1] = -1; for(int j = 0; j < 2 * n; j++){ if(p[ v[j].first ] == -1) p[ v[j].first ] = j; else{ if( (j - p[ v[j].first ]) % m == 0 ){ ok = 0; break; } } } if(ok) cnt++; next_permutation(v.begin(), v.end()); } cout << cnt << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...