제출 #1247356

#제출 시각아이디문제언어결과실행 시간메모리
1247356_asunaaBroken Device (JOI17_broken_device)C++20
0 / 100
19 ms1600 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; long long i, j, l, r, mid, p, q, k, t, n, m, b, c, d, ans, cnt, res, arr[1000005]; int a[40]; const long long mod = 999993143, mod2 = 999993469; bool check; //void Set (int a, int b){ // cout << b; //} void Anna (int N, long long X, int K, int P[]){ string s = " "; while (X > 1){ s.push_back((char)(X % 2 + 48)); X /= 2; } s.push_back((char)(X + 48)); d = s.length() - 1; // cout << s << "\n"; p = 1; for (i = 1; i <= N; i += 1){ arr[i] = 0; } for (i = 0; i < K; i += 1){ arr[P[i]] = 1; } for (i = 1; i <= N; i += 3){ res = arr[i] + arr[i + 1] + arr[i + 2]; if (res >= 2 || p > d){ Set(i - 1, 0); Set(i, 0); Set(i + 1, 0); } else if (res == 1){ if (p == d){ s += "0"; } if (s[p] == 49){ if (arr[i] == 1){ Set(i - 1, 0); Set(i, 1); Set(i + 1, 1); } else{ Set(i - 1, 1); Set(i, 0); Set(i + 1, 0); } p += 1; } else{ if (arr[i + 2] == 1){ if (s[p + 1] == 48){ Set(i - 1, 0); Set(i, 1); Set(i + 1, 0); } else{ Set(i - 1, 1); Set(i, 1); Set(i + 1, 0); } p += 2; } else{ Set(i - 1, 0); Set(i, 0); Set(i + 1, 1); p += 1; } } } else{ if (p == d){ s += "0"; } if (s[p] == 49 && s[p + 1] == 49){ Set(i - 1, 1); Set(i, 1); Set(i + 1, 1); } else if (s[p] == 49 && s[p + 1] == 48){ Set(i - 1, 1); Set(i, 0); Set(i + 1, 1); } else if (s[p] == 48 && s[p + 1] == 49){ Set(i - 1, 1); Set(i, 1); Set(i + 1, 0); } else{ Set(i - 1, 0); Set(i, 1); Set(i + 1, 0); } p += 2; } } return; } //int main(){ // for (i = 0; i < 40; i += 1){ // a[i] = i * 2; // } // Anna(150, 192839, 40, a); //}
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; long long i, j, l, r, mid, p, q, k, t, n, m, b, c, d, ans, cnt, res, arr[1000005]; int a[150]; const long long mod = 999993143, mod2 = 999993469; bool check; string ss = "100000100000100000001000001000001000100000001000100000001000001000001000100000111101101000000000000000000000000000000000000000000000000000000000000000"; long long Bruno (int N, int A[]){ string s; ans = 0; s = " "; for (i = 1; i <= N; i += 3){ if (A[i - 1] == 0 && A[i] == 0 && A[i + 1] == 0){ continue; } else if (A[i - 1] == 0 && A[i] == 0 && A[i + 1] == 1){ s += "0"; } else if (A[i - 1] == 0 && A[i] == 1 && A[i + 1] == 0){ s += "00"; } else if (A[i - 1] == 0 && A[i] == 1 && A[i + 1] == 1){ s += "1"; } else if (A[i - 1] == 1 && A[i] == 0 && A[i + 1] == 0){ s += "1"; } else if (A[i - 1] == 1 && A[i] == 0 && A[i + 1] == 1){ s += "10"; } else if (A[i - 1] == 1 && A[i] == 1 && A[i + 1] == 0){ s += "01"; } else{ s += "11"; } // cout << s << "\n"; } // cout << s << "\n"; for (i = 1; i < s.length(); i += 1){ ans += (long long)(s[i] - 48) * (1ll << (i - 1)); } return ans; } //int main(){ // for (i = 0; i < 150; i += 1){ // a[i] = (long long)(ss[i]) - 48; //// cout << a[i]; // } //// cout << "\n"; // cout << Bruno(150, a); //}
#Verdict Execution timeMemoryGrader output
Fetching results...