QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#227219 | #7190. Chessboard | PPP | Compile Error | / | / | C++17 | 4.3kb | 2023-10-27 03:00:06 | 2023-10-27 03:00:07 |
Judging History
answer
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef double ld;
int n, m;
const int maxN = 205;
int cnt_other[4 * maxN];
int info[4 * maxN][maxN][2];
int tp[maxN][maxN];
int q;
int MP[4 * maxN];
int SZ[4 * maxN];
int EDGE[2 * maxN][2 * maxN];
int CNT[4 * maxN];
int id[4 * maxN];
int Q[4 * maxN];
int ITER = 0;
int inter[4 * maxN];
void merge(int v, int l, int mid, int r) {
cnt_other[v] = cnt_other[2 * v] + cnt_other[2 * v + 1];
int SZ1 = SZ[2 * v];
int SZ2 = SZ[2 * v + 1];
for (int u = 0; u < SZ1 + SZ2; u++) {
id[u] = u;
CNT[u] = u;
}
for (int x = 1; x <= m; x++) {
if (tp[mid][x] == tp[mid + 1][x]) {
int P = info[2 * v][x][1];
int Q = info[2 * v + 1][x][0] + SZ1;
if (CNT[P] > 0 && EDGE[P][CNT[P] - 1] == Q) continue;
EDGE[P][CNT[P]] = Q;
EDGE[Q][CNT[Q]] = P;
CNT[P]++;
CNT[Q]++;
}
}
ITER++;
for (int x = 1; x <= m; x++) {
int u = info[2 * v][x][1];
if (id[u] == u && inter[u] != ITER) {
int topQ = 0;
Q[topQ++] = u;
inter[u] = ITER;
for (int z = 0; z < topQ; z++) {
int vert = Q[z];
for (int p = 0; p < CNT[vert]; p++) {
if (id[EDGE[vert][p]] == EDGE[vert][p] && EDGE[vert][p] != u) {
id[EDGE[vert][p]] = u;
Q[topQ++] = EDGE[vert][p];
}
}
}
}
}
ITER++;
for (int x = 1; x <= m; x++) {
inter[id[info[2 * v][x][0]]] = ITER;
inter[id[info[2 * v + 1][x][1] + SZ1]] = ITER;
}
int sz = 0;
int CMP = 0;
for (int u = 0; u < SZ1 + SZ2; u++) {
if (id[u] == u) {
if (inter[u] != ITER) {
CMP++;
}
else {
MP[u] = sz;
sz++;
}
}
}
cnt_other[v] += CMP;
for (int x = 1; x <= m; x++) {
info[v][x][0] = MP[id[info[2 * v][x][0]]];
}
for (int x = 1; x <= m; x++) {
info[v][x][1] = MP[id[info[2 * v + 1][x][1] + SZ1]];
}
SZ[v] = sz;
}
void build(int v, int tl, int tr) {
if (tl == tr) {
cnt_other[v] = 0;
int sz = 0;
for (int j = 1; j <= m; j++) {
if (j == 1 || tp[tl][j] != tp[tl][j - 1]) {
info[v][j][0] = info[v][j][1] = sz;
sz++;
} else {
info[v][j][0] = info[v][j][1] = info[v][j - 1][0];
}
}
SZ[v] = sz;
return;
}
int tm = (tl + tr) / 2;
build(2 * v, tl, tm);
build(2 * v + 1, tm + 1, tr);
merge(v, tl, tm, tr);
}
int calc() {
return SZ[1] + cnt_other[1];
}
void upd(int v, int tl, int tr, int pos) {
if (tl == tr) {
cnt_other[v] = 0;
int sz = 0;
for (int j = 1; j <= m; j++) {
if (j == 1 || tp[tl][j] != tp[tl][j - 1]) {
info[v][j][0] = info[v][j][1] = sz;
sz++;
} else {
info[v][j][0] = info[v][j][1] = info[v][j - 1][0];
}
}
SZ[v] = sz;
return;
}
int tm = (tl + tr) / 2;
if (pos <= tm) {
upd(2 * v, tl, tm, pos);
} else {
upd(2 * v + 1, tm + 1, tr, pos);
}
merge(v, tl, tm, tr);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
cin >> n >> m >> q;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char c;
cin >> c;
if (c == '1') tp[i][j] = 1;
}
}
build(1, 1, n);
int op = calc();
while (q--) {
int x, y;
cin >> x >> y;
x ^= op;
y ^= op;
tp[x][y] ^= 1;
upd(1, 1, n, x);
op = calc();
cout << op << '\n';
}
return 0;
}
Details
answer.code:4:74: warning: bad option ‘-f unroll-loops’ to pragma ‘optimize’ [-Wpragmas] 4 | #pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline") | ^ answer.code:6:82: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes] 6 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2") | ^ answer.code:6:82: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes] answer.code:6:82: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes] answer.code:6:82: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes] In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/gthr.h:148, from /usr/include/c++/11/ext/atomicity.h:35, from /usr/include/c++/11/bits/ios_base.h:39, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:8: /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 102 | __gthrw(pthread_once) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 103 | __gthrw(pthread_getspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 104 | __gthrw(pthread_setspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 106 | __gthrw(pthread_create) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 107 | __gthrw(pthread_join) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 108 | __gthrw(pthread_equal) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 109 | __gthrw(pthread_self) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 110 | __gthrw(pthread_detach) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 112 | __gthrw(pthread_cancel) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 114 | __gthrw(sched_yield) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 116 | __gthrw(pthread_mutex_lock) | ^~~~~~~ /usr/include/x86_64-linux...