Submission #555384

#TimeUsernameProblemLanguageResultExecution timeMemory
555384LucaDantasGroup Photo (JOI21_ho_t3)C++17
5 / 100
3 ms340 KiB
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 11; int a[maxn], b[maxn]; bool mark[maxn]; bool valid(int n) { for(int i = 1; i < n; i++) if(b[i] + 2 <= b[i-1]) return 0; return 1; } int get(int n) { memset(mark, 1, sizeof mark); int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; a[j] != b[i]; j++) ans += mark[a[j]]; mark[b[i]] = 0; } return ans; } int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); iota(b, b+n, 1); int ans = 0x3f3f3f3f; do { if(valid(n)) ans = min(ans, get(n)); } while(next_permutation(b, b+n)); printf("%d\n", ans); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
Main.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", &a[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...