# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1048025 | 2024-08-07T20:24:27 Z | Lobo | Sequence (BOI14_sequence) | C++17 | 1000 ms | 464 KB |
#include<bits/stdc++.h> using namespace std; const long long inf = 1e18 + 10; const int inf1 = 1e9 + 10; #define int long long #define dbl long double #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const int maxn = -1; set<int> digits(int x) { set<int> s; while(x != 0) { s.insert(x%10); x/= 10; } return s; } int ans = inf; int sol(vector<set<int>> a) { if(a.size() == 0) { return 0; } int ans = inf; for(int y = 0; y <= 9; y++) { vector<set<int>> b; for(int i = 0; i < a.size(); i++) { for(auto ele : a[i]) { if(ele != (y+i)%10) { if((y+i)/10 >= (int) b.size()) b.resize((y+i)/10 + 1); b[(y+i)/10].insert(ele); } } } if(a != b) { ans = min(ans, y + 10*sol(b)); } } return ans; } void solve() { int k; cin >> k; vector<int> b(k); vector<set<int>> setb(k); for(int i = 0; i < k; i++) { cin >> b[i]; setb[i].insert(b[i]); } cout << sol(setb) << endl; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE // freopen("in.in", "r", stdin); // freopen("out.out", "w", stdout); #endif int tt = 1; // cin >> tt; while(tt--) { solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 344 KB | Output is correct |
2 | Execution timed out | 1030 ms | 344 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 344 KB | Output is correct |
2 | Execution timed out | 1091 ms | 348 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 464 KB | Output is correct |
2 | Execution timed out | 1087 ms | 348 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |