Submission #871038

#TimeUsernameProblemLanguageResultExecution timeMemory
871038Ahmed57NoM (RMI21_nom)C++17
9 / 100
1035 ms600 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); int n,k; cin>>n>>k; vector<int>v; for(int i = 0;i<n;i++){ v.push_back(i);v.push_back(i+n); } sort(v.begin(),v.end()); long long ans = 0; do{ int la[n]= {0};bool ss = 1; for(int i = 0;i<v.size();i++){ if(la[v[i]%n]!=0){ if(abs((i+1)-la[v[i]%n])%k==0){ ss = 0; break; } } la[v[i]%n] = i+1; } if(ss)ans++; }while(next_permutation(v.begin(),v.end())); cout<<ans<<endl; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:16:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int i = 0;i<v.size();i++){
      |                       ~^~~~~~~~~
#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...