Submission #522398

#TimeUsernameProblemLanguageResultExecution timeMemory
522398LucaDantasAlternating Current (BOI18_alternating)C++17
13 / 100
3058 ms332 KiB
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 20; using pii = pair<int,int>; int a[maxn], b[maxn]; bool mark[maxn][2]; int main() { int n, m; scanf("%d %d", &n, &m); for(int i = 0; i < m; i++) scanf("%d %d", &a[i], &b[i]); vector<int> ans(m); for(int mask = 0; mask < (1 << m); mask++) { memset(mark, 0, sizeof mark); for(int i = 0; i < m; i++) { int tp = (mask&(1<<i)) > 0; for(int j = a[i]; j != b[i]; j = j%n +1) mark[j][tp] = 1; mark[b[i]][tp] = 1; } bool ok = 1; for(int i = 1; i <= n; i++) if(!mark[i][0] || !mark[i][1]) ok = 0; if(ok) { for(int i = 0; i < m; i++) printf("%d", (mask&(1<<i)) > 0); puts(""); return 0; } } puts("impossible"); }

Compilation message (stderr)

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