Submission #107800

#TimeUsernameProblemLanguageResultExecution timeMemory
107800dfistricSequence (BOI14_sequence)C++14
100 / 100
274 ms1532 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define FORd(i, a, b) for (int i = (a); i >= (b); i--) #define REP(i, n) FOR(i, 0, n) #define ll long long using namespace std; ll rek(vector <int> ve, int flag) { if (ve.size() == 1) { ll out = 0; int a = ve[0]; FOR(i, 1, 10) { if (a & (1 << i)) out = out * 10 + i; if (out == i && (a & 1)) out *= 10; } if (out == 0 && (a & 1)) out = 10; return out; } ll out = 102345678900000LL; REP(n, 9 + flag) { int y = n, fl = 0, tr = 0; vector <int> tmp; REP(i, ve.size()) { int a = ve[i]; tr |= ((1023 ^ (1 << y)) & a); if (y == 0 && (a & 1)) fl = 1; y = (y + 1) % 10; if (y == 0 || i == ve.size() - 1) tmp.push_back(tr), tr = 0; } ll curr = rek(tmp, n < 9 || ve.size() > 2) * 10 + n; if (curr == 0 && fl) curr = 10; out = min(out, curr); } return out; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector <int> tmp; REP(i, n) { int x; cin >> x; tmp.push_back((1 << x)); } cout << rek(tmp, 1) << endl; return 0; }

Compilation message (stderr)

sequence.cpp: In function 'long long int rek(std::vector<int>, int)':
sequence.cpp:3:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(i, a, b) for (int i = (a); i < (b); i++)
                                          ^
sequence.cpp:5:19: note: in expansion of macro 'FOR'
 #define REP(i, n) FOR(i, 0, n)
                   ^~~
sequence.cpp:30:9: note: in expansion of macro 'REP'
         REP(i, ve.size()) {
         ^~~
sequence.cpp:36:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (y == 0 || i == ve.size() - 1) tmp.push_back(tr), tr = 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...