Submission #381997

#TimeUsernameProblemLanguageResultExecution timeMemory
381997VEGAnnHop (COCI21_hop)C++14
0 / 110
1095 ms364 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define PB push_back #define i2 array<int,2> using namespace std; typedef long long ll; const int MX = int(1e7) + 10; const int oo = 2e9; const int N = 1010; ll x[N]; int n; int dp[N][3]; void BAD(){ cout << "BAD" << endl; while (1) {} } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n; /// хотя бы один должен быть доступен, иначе ban for (int i = 1; i <= n; i++) cin >> x[i]; // for (int t1 = 0; t1 < 4; t1++) // for (int t2 = 0; t2 < 4; t2++) // for (int t3 = 0; t3 < 4; t3++) // dp[1][t1][t2][t3] = dp[1][0] = dp[1][1] = dp[1][2] = 0; for (int i = 2; i <= n; i++){ dp[i][0] = dp[i][1] = dp[i][2] = 0; for (int j = 1; j < i; j++){ if (x[i] % x[j] == 0) { if (dp[i][0] == 2 && dp[i][1] == 2 && dp[i][2] == 2) BAD(); int mn = oo, id = -1; for (int z = 0; z < 3; z++) if (mn > dp[j][z] + 1){ mn = dp[j][z] + 1; id = z; } dp[i][id] = max(dp[i][id], mn); cout << id + 1 << " "; } else cout << "1 "; } cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...