#include <bits/stdc++.h>
#include <Annalib.h>
using namespace std;
pair<int,int> mask_to_num(int m){
if(m == 7) return {3,2};
if(m == 6) return {1,2};
if(m == 5) return {2,2};
if(m == 4) return {1,1};
if(m == 3) return {1,1};
if(m == 2) return {0,2};
if(m == 1) return {0,1};
if(m == 0) return {0,0};
}
int num_to_mask(int n){
for(int i = 1;i < 7;i++){
if(mask_to_num(i).second == 2 and mask_to_num(i).first == n) return i;
}
}
void Anna( int N, long long X, int K, int P[] ){
vector<int> L(N,-2);
stack<int> B;
while(X) B.push(X%2), X/=2;
while(B.size()%2 != 0) B.push(0);
for(int i = 0;i < K;i++) L[P[i]] = -1;
for(int i = 0;i < N;i+=3){
if(L[i]+L[i+1]+L[i+2] > -5 or B.empty()) {
Set(i,0);
Set(i+1,0);
Set(i+2,0);
continue;
}
if(L[i]+L[i+1]+L[i+2] == -6){
if(B.empty()) B.push(0);
int a = B.top();
B.pop();
if(B.empty()) B.push(0);
int b = B.top();
B.pop();
int c = num_to_mask(a*2+b);
Set(i,c/4);
Set(i+1,(c/2)%2);
Set(i+2,c%2);
}
else{
if(B.empty()) B.push(0);
int a = B.top();
B.pop();
if(a == 1 and L[i] == -2){
Set(i,1);
Set(i+1,0);
Set(i+2,0);
}
else if(a == 1){
Set(i,0);
Set(i+1,1);
Set(i+2,1);
}
else if(a == 0 and L[i+2] == -2){
Set(i,0);
Set(i+1,0);
Set(i+2,1);
}
else{
if(B.empty()) B.push(0);
int b = B.top();
B.pop();
Set(i,b);
Set(i+1,1);
Set(i+2,0);
}
}
}
}
#include <bits/stdc++.h>
#include <Brunolib.h>
using namespace std;
pair<int,int> mask_to_num(int m){
if(m == 7) return {3,2};
if(m == 6) return {1,2};
if(m == 5) return {2,2};
if(m == 4) return {1,1};
if(m == 3) return {1,1};
if(m == 2) return {0,2};
if(m == 1) return {0,1};
if(m == 0) return {0,0};
}
int num_to_mask(int n){
for(int i = 1;i < 7;i++){
if(mask_to_num(i).second == 2 and mask_to_num(i).first == n) return i;
}
}
long long Bruno( int N, int A[] ){
long long X = 0;
int cnt = 0;
for(int i = 0;i < N;i+=3){
pair<int,int> a = mask_to_num(A[i]*4+A[i+1]*2+A[i+2]);
if(a.second == 0) continue;
if(a.second == 1 and cnt < 60){
cnt++;
X = X<<1|a.first;
}
if(a.second and cnt < 59){
cnt+=2;
X = X<<2|a.first;
}
else if(a.second and cnt < 60){
cnt+=1;
X = X<<1|(a.first>>1);
}
}
return X;
}
Compilation message
Anna.cpp: In function 'std::pair<int, int> mask_to_num(int)':
Anna.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
13 | }
| ^
Anna.cpp: In function 'int num_to_mask(int)':
Anna.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
18 | }
| ^
Bruno.cpp: In function 'std::pair<int, int> mask_to_num(int)':
Bruno.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
13 | }
| ^
Bruno.cpp: In function 'int num_to_mask(int)':
Bruno.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
18 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2095 ms |
348 KB |
Time limit exceeded |
2 |
Execution timed out |
2015 ms |
344 KB |
Time limit exceeded |
3 |
Execution timed out |
2033 ms |
348 KB |
Time limit exceeded |
4 |
Execution timed out |
2064 ms |
348 KB |
Time limit exceeded |
5 |
Execution timed out |
2056 ms |
348 KB |
Time limit exceeded |
6 |
Execution timed out |
2023 ms |
348 KB |
Time limit exceeded |
7 |
Execution timed out |
2027 ms |
348 KB |
Time limit exceeded |
8 |
Execution timed out |
2012 ms |
556 KB |
Time limit exceeded |
9 |
Execution timed out |
2024 ms |
344 KB |
Time limit exceeded |
10 |
Execution timed out |
2064 ms |
348 KB |
Time limit exceeded |
11 |
Execution timed out |
2049 ms |
348 KB |
Time limit exceeded |
12 |
Execution timed out |
2021 ms |
344 KB |
Time limit exceeded |
13 |
Execution timed out |
2027 ms |
348 KB |
Time limit exceeded |
14 |
Execution timed out |
2024 ms |
344 KB |
Time limit exceeded |
15 |
Execution timed out |
2037 ms |
348 KB |
Time limit exceeded |
16 |
Execution timed out |
2004 ms |
344 KB |
Time limit exceeded |
17 |
Execution timed out |
2044 ms |
348 KB |
Time limit exceeded |
18 |
Execution timed out |
2064 ms |
348 KB |
Time limit exceeded |
19 |
Execution timed out |
2013 ms |
344 KB |
Time limit exceeded |
20 |
Execution timed out |
2049 ms |
348 KB |
Time limit exceeded |
21 |
Execution timed out |
2017 ms |
344 KB |
Time limit exceeded |
22 |
Execution timed out |
2013 ms |
344 KB |
Time limit exceeded |
23 |
Execution timed out |
2051 ms |
348 KB |
Time limit exceeded |
24 |
Execution timed out |
2067 ms |
348 KB |
Time limit exceeded |
25 |
Execution timed out |
2041 ms |
348 KB |
Time limit exceeded |
26 |
Execution timed out |
2039 ms |
348 KB |
Time limit exceeded |
27 |
Execution timed out |
2053 ms |
348 KB |
Time limit exceeded |
28 |
Execution timed out |
2029 ms |
344 KB |
Time limit exceeded |
29 |
Execution timed out |
2055 ms |
348 KB |
Time limit exceeded |
30 |
Execution timed out |
2056 ms |
348 KB |
Time limit exceeded |
31 |
Execution timed out |
2021 ms |
344 KB |
Time limit exceeded |
32 |
Execution timed out |
2037 ms |
348 KB |
Time limit exceeded |
33 |
Execution timed out |
2025 ms |
344 KB |
Time limit exceeded |
34 |
Execution timed out |
2057 ms |
348 KB |
Time limit exceeded |
35 |
Execution timed out |
2055 ms |
348 KB |
Time limit exceeded |
36 |
Execution timed out |
2043 ms |
348 KB |
Time limit exceeded |
37 |
Execution timed out |
2033 ms |
344 KB |
Time limit exceeded |
38 |
Execution timed out |
2052 ms |
348 KB |
Time limit exceeded |
39 |
Execution timed out |
2058 ms |
348 KB |
Time limit exceeded |
40 |
Execution timed out |
2057 ms |
600 KB |
Time limit exceeded |