# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1048060 | 2024-08-07T20:56:26 Z | Lobo | 수열 (BOI14_sequence) | C++17 | 662 ms | 22612 KB |
#include<bits/stdc++.h> using namespace std; const long long inf = 1e17 + 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 sol(int qtd, vector<set<int>> a) { if(a.size() == 0) { return 0; } else if(a.size() == 1) { int ans = 0; vector<int> vec; for(auto x : a[0]) { vec.pb(x); } if(vec[0] == 0) { if(vec.size() == 1) vec = {1,0}; else swap(vec[0],vec[1]); } for(auto x : vec) { ans = 10*ans + x; } return ans; } if(qtd > 5) return inf; 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 or true) { ans = min(ans, y + 10*sol(qtd+1,b)); // } // if(qtd == 0) { // int kkk = sol(qtd+1,b); // cout << y << " " << kkk << " " << b.size() << endl; // } // if(qtd == 1 && a.size() == 36) { // cout << " " << y << " " << sol(qtd+1,b) << " " << b.size() << endl; // } } 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(0,setb) << endl; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); int tt = 1; // cin >> tt; while(tt--) { solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 10 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 492 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 1 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 10 ms | 344 KB | Output is correct |
3 | Correct | 4 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 25 ms | 2940 KB | Output is correct |
3 | Correct | 25 ms | 2904 KB | Output is correct |
4 | Correct | 18 ms | 2908 KB | Output is correct |
5 | Correct | 18 ms | 2908 KB | Output is correct |
6 | Correct | 21 ms | 2140 KB | Output is correct |
7 | Correct | 127 ms | 15668 KB | Output is correct |
8 | Correct | 89 ms | 10220 KB | Output is correct |
9 | Correct | 190 ms | 22612 KB | Output is correct |
10 | Correct | 178 ms | 22440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 12 ms | 568 KB | Output is correct |
3 | Correct | 3 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 662 ms | 11876 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |