Submission #902659

#TimeUsernameProblemLanguageResultExecution timeMemory
902659nguyentunglamBroken Device (JOI17_broken_device)C++17
55 / 100
40 ms2692 KiB
#include "Annalib.h" #include<bits/stdc++.h> using namespace std; namespace { mt19937 rng(1); } void Anna( int n, long long x, int k, int p[] ){ vector<bool> broken(n); vector<int> order(n); for(int i = 0; i < n; i++) order[i] = i; shuffle(order.begin(), order.end(), rng); for(int i = 0; i < n; i++) broken[i] = 0; for(int i = 0; i < k; i++) broken[p[i]] = 1; for(int i = 0, pre = -1, j = 59; i < n; i++) { if (broken[order[i]] || j < 0) { Set(order[i], 0); continue; } bool a = x >> j & 1; bool b = i - pre - 1 & 1; if (a == b) { pre = i; j--; Set(order[i], 1); } else Set(order[i], 0); } }
#include "Brunolib.h" #include<bits/stdc++.h> using namespace std; namespace { mt19937 rng(1); } long long Bruno( int n, int a[] ){ long long x = 0; vector<int> order(n); for(int i = 0; i < n; i++) order[i] = i; shuffle(order.begin(), order.end(), rng); // for(int i = 0; i < n; i++) cout << order[i] << " "; cout << endl; for(int i = 0, pre = -1, j = 59; i < n && j >= 0; i++) if (a[order[i]]) { bool bit = i - pre - 1 & 1; if (bit) x |= (1LL << j); j--; pre = i; } // cout << "answer :" << x << endl; return x; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:23:22: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   23 |     bool b = i - pre - 1 & 1;
      |              ~~~~~~~~^~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:17:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   17 |     bool bit = i - pre - 1 & 1;
      |                ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...