#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;
void Anna(int n, int K, std::vector<int> R, std::vector<int> C){
int label[n][n];
memset(label, 0, sizeof(label));
///handle left
for(int c = 0;c < n;c++){
if(c == 0){
for(int r = 0;r < n;r++) label[r][c] += 0;
}
else{
int res = 0;
for(int i = 0;i < K;i++){
if(C[i] <= c) res += (1<<i);
}
int a = res / 36, b = (res / 6) % 6, C = res % 6;
int s[3] = {a,b,C};
//show2(c, res);
for(int r = 0;r < n;r++) label[r][c] = s[r%3];
}
}
for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) label[i][j] *= 6;
///handle up
for(int r = 0;r < n;r++){
if(r == 0){
for(int c = 0;c < n;c++) label[r][c] = 0;
}
else{
int res = 0;
for(int i = 0;i < K;i++){
if(R[i] <= r) res += (1<<i);
}
int a = res / 36, b = (res / 6) % 6, c = res % 6;
int s[3] = {a,b,c};
for(int c = 0;c < n;c++) label[r][c] += s[c%3];
}
}
for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) label[i][j] *= 2;
for(int r = 0;r < n;r += 3){
for(int c = 0;c < n;c += 3) label[r][c]++;
}
for(int r = 0;r < n;r ++){
for(int c = 0;c < n;c ++) SetFlag(r,c,label[r][c]+1);
}
for(int r = 0;r < n;r++){
for(int c = 0;c < n;c++){
//cout << label[r][c] << " ";
}
//cout << '\n';
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;
deque<int> conv(deque<int> A){
int res = A[0] * 36 + A[1] * 6 + A[2];
deque<int> ret;
for(int i = 0;i < 7;i++){
ret.push_back(res&1);
res /= 2;
}
return ret;
}
std::vector<int> Bruno(int K, std::vector<int> value) {
std::vector<int> ans(K, 0);
for(int &x : value) x--;
int dr = 0, dc = 0;
for(int i = 0;i < 9;i++){
if(value[i] & 1){
dr = i % 3, dc = i/3;
break;
}
}
for(int &x : value) x /= 2;
//for(int &x : value) cerr << x << " "; cerr << '\n';
deque<int> L1 = {value[0]/6, value[3]/6, value[6]/6};
deque<int> L2 = {value[1]/6, value[4]/6, value[7]/6};
deque<int> U1 = {value[0]%6, value[1]%6, value[2]%6};
deque<int> U2 = {value[3]%6, value[4]%6, value[5]%6};
for(int i = 0;i < dc;i++){
L1.push_back(L1.front());
L1.pop_front();
}
for(int i = 0;i < dc;i++){
L2.push_back(L2.front());
L2.pop_front();
}
for(int i = 0;i < dr;i++){
U1.push_back(U1.front());
U1.pop_front();
}
for(int i = 0;i < dr;i++){
U2.push_back(U2.front());
U2.pop_front();
}
L1 = conv(L1);
L2 = conv(L2);
U1 = conv(U1);
U2 = conv(U2);
//for(int x : L1) cerr << x << " "; cerr << '\n';
//for(int x : L2) cerr << x << " "; cerr << '\n';
//for(int x : U1) cerr << x << " "; cerr << '\n';
//for(int x : U2) cerr << x << " "; cerr << '\n';
for(int i = 0;i < K;i++){
if(L1[i] and not L2[i]) assert(false);
if(U1[i] and not U2[i]) assert(false);
if(L1[i]) ans[i] = 1;
else if(not L2[i]) ans[i] = 0;
else if(U1[i]) ans[i] = 3;
else if(not U2[i]) ans[i] = 2;
else ans[i] = 4;
}
//for(int x : ans) cerr << x << " "; cerr << '\n';
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
192 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |