QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#56940 | #3873. Towers | Janus | Compile Error | / | / | C++ | 5.9kb | 2022-10-21 22:33:14 | 2022-10-21 22:33:17 |
Judging History
This is the latest submission verdict.
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-10-21 22:33:17]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2022-10-21 22:33:14]
- Submitted
answer
#include<bits/stdc++.h>
#define MAXN 1000001
using namespace std;
struct coor{ int x, y; };
bool operator < (coor a, coor b){
if(a.x == b.x) return a.y < b.y;
return a.x < b.x;
}
bool operator > (coor a, coor b){
if(a.x == b.x) return a.y > b.y;
return a.x > b.x;
}
bool operator < (coor a, int b){ return a.y < b; }
bool operator > (coor a, int b){ return a.y > b; }
int n, nx, ny;
int dx[MAXN], dy[MAXN];
coor tower[MAXN];
namespace gouzao{
vector<coor> tx[MAXN]; // x 坐标为 i 的塔的集合
priority_queue<int> cy[MAXN]; // y 坐标为 i 时已选择的塔的 x 坐标的集合
int idx[MAXN]; // x 坐标为 i 时所选择的 y 坐标较小的塔
int ans[MAXN], res[MAXN], siz[MAXN];
void from_r_to_l(int op){
// priority_queue<int> cy[MAXN]; // y 坐标为 i 时已选择的塔的 x 坐标的集合
for(int i = 1; i <= ny; i++) while(cy[i].size()) cy[i].pop();
for(int i = 1; i <= n; i++) if(ans[tower[i].id]) cy[tower[i].y].push(tower[i].x);
for(int i = 1; i <= nx; i++) idx[i] = tx[i].size() - 1;
priority_queue<int> q;
for(int i = ny; i >= 1; i--){
if(cy[i].size() > 2) q.push(i);
}
while(!q.empty()){
int i = q.top(); q.pop();
cy[i].pop();
while(cy[i].size() > 1){
int now = cy[i].top(); cy[i].pop();
idx[now] = lower_bound(tx[now].begin(), tx[now].begin() + idx[now] + 1, i) - tx[now].begin();
if(idx[now] - op < 0) continue;
if(ans[tx[now][idx[now]].id] == 0) continue;
ans[tx[now][idx[now]].id] = 0; idx[now]--;
if(idx[now] >= 0 && ans[tx[now][idx[now]].id] == 0){
int nowy = tx[now][idx[now]].y;
cy[nowy].push(now);
if(cy[nowy].size() == 3) q.push(nowy);
ans[tx[now][idx[now]].id] = 1;
}
}
}
}
void from_l_to_r(int op){
// priority_queue<int> cy[MAXN]; // y 坐标为 i 时已选择的塔的 x 坐标的集合
for(int i = 1; i <= ny; i++) while(cy[i].size()) cy[i].pop();
for(int i = 1; i <= n; i++) if(ans[tower[i].id]) cy[tower[i].y].push(tower[i].x);
for(int i = 1; i <= nx; i++) idx[i] = 0;
priority_queue<int, vector<int>, greater<int> > q;
for(int i = 1; i <= ny; i++){
if(cy[i].size() > 2) q.push(i);
}
while(!q.empty()){
int i = q.top(); q.pop();
cy[i].pop();
while(cy[i].size() > 1){
int now = cy[i].top(); cy[i].pop();
idx[now] = lower_bound(tx[now].begin() + idx[now], tx[now].end(), i) - tx[now].begin();
if(idx[now] + op >= siz[now]) continue;
if(ans[tx[now][idx[now]].id] == 0) continue;
ans[tx[now][idx[now]].id] = 0; idx[now]++;
if(idx[now] < siz[now] && ans[tx[now][idx[now]].id] == 0){
int nowy = tx[now][idx[now]].y;
cy[nowy].push(now);
if(cy[nowy].size() == 3) q.push(nowy);
ans[tx[now][idx[now]].id] = 1;
}
}
}
}
void radix_sort(int n, coor a[]){
coor *b = new coor[n];
int *cnt = new int[1 << 16];
int mask = (1 << 16) - 1;
coor *x = a, *y = b;
for(int i = 0; i < 32; i += 16){
for(int j = 0; j < (1 << 16); j++) cnt[j] = 0;
for(int j = 0; j < n; j++) ++cnt[x[j].y >> i & mask];
for(int sum = 0, j = 0; j < (1 << 16); j++){
sum += cnt[j]; cnt[j] = sum - cnt[j];
}
for(int j = 0; j < n; j++) y[cnt[x[j].y >> i & mask]++] = x[j];
swap(x, y);
}
for(int i = 0; i < 32; i += 16){
for(int j = 0; j < (1 << 16); j++) cnt[j] = 0;
for(int j = 0; j < n; j++) ++cnt[x[j].x >> i & mask];
for(int sum = 0, j = 0; j < (1 << 16); j++){
sum += cnt[j]; cnt[j] = sum - cnt[j];
}
for(int j = 0; j < n; j++) y[cnt[x[j].x >> i & mask]++] = x[j];
swap(x, y);
}
delete[] cnt; delete[] b;
}
void main(){
radix_sort(n, tower + 1);
for(int i = 1; i <= n; i++) tx[tower[i].x].push_back(tower[i]);
for(int i = 1; i <= nx; i++) siz[i] = tx[i].size();
for(int i = 1; i <= nx; i++){
if(idx[i] < siz[i]){
ans[tx[i][0].id] = 1;
if(siz[i] != 1) ans[tx[i][siz[i] - 1].id] = 1;
}
}
for(int i = 1; i <= 4; i++){
from_l_to_r(1);
from_r_to_l(1);
}
from_l_to_r(0);
for(int i = 1; i <= n; i++) putchar(ans[i] + '0');
printf("\n");
}
}
void radix_sort(int n, int a[]){
int *b = new int[n];
int *cnt = new int[1 << 16];
int mask = (1 << 16) - 1;
int *x = a, *y = b;
for(int i = 0; i < 32; i += 16){
for(int j = 0; j < (1 << 16); j++) cnt[j] = 0;
for(int j = 0; j < n; j++) ++cnt[x[j] >> i & mask];
for(int sum = 0, j = 0; j < (1 << 16); j++){
sum += cnt[j]; cnt[j] = sum - cnt[j];
}
for(int j = 0; j < n; j++) y[cnt[x[j] >> i & mask]++] = x[j];
swap(x, y);
}
delete[] cnt;
delete[] b;
}
int main(){
scanf("%d",&n);
for(int i = 1; i <= n; i++) scanf("%d%d",&tower[i].x,&tower[i].y),;
for(int i = 1; i <= n; i++) dx[i] = tower[i].x, dy[i] = tower[i].y;
radix_sort(n, dx + 1); radix_sort(n, dy + 1);
nx = unique(dx + 1, dx + n + 1) - dx - 1;
ny = unique(dy + 1, dy + n + 1) - dy - 1;
for(int i = 1; i <= n; i++) tower[i].x = lower_bound(dx + 1, dx + nx + 1, tower[i].x) - dx;
for(int i = 1; i <= n; i++) tower[i].y = lower_bound(dy + 1, dy + ny + 1, tower[i].y) - dy;
gouzao::main();
return 0;
}
Details
answer.code: In function ‘void gouzao::from_r_to_l(int)’: answer.code:26:53: error: ‘struct coor’ has no member named ‘id’ 26 | for(int i = 1; i <= n; i++) if(ans[tower[i].id]) cy[tower[i].y].push(tower[i].x); | ^~ answer.code:39:42: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 39 | if(ans[tx[now][idx[now]].id] == 0) continue; | ^~ answer.code:40:39: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 40 | ans[tx[now][idx[now]].id] = 0; idx[now]--; | ^~ answer.code:41:59: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 41 | if(idx[now] >= 0 && ans[tx[now][idx[now]].id] == 0){ | ^~ answer.code:45:43: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 45 | ans[tx[now][idx[now]].id] = 1; | ^~ answer.code: In function ‘void gouzao::from_l_to_r(int)’: answer.code:53:53: error: ‘struct coor’ has no member named ‘id’ 53 | for(int i = 1; i <= n; i++) if(ans[tower[i].id]) cy[tower[i].y].push(tower[i].x); | ^~ answer.code:66:42: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 66 | if(ans[tx[now][idx[now]].id] == 0) continue; | ^~ answer.code:67:39: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 67 | ans[tx[now][idx[now]].id] = 0; idx[now]++; | ^~ answer.code:68:65: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 68 | if(idx[now] < siz[now] && ans[tx[now][idx[now]].id] == 0){ | ^~ answer.code:72:43: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 72 | ans[tx[now][idx[now]].id] = 1; | ^~ answer.code: In function ‘void gouzao::main()’: answer.code:108:30: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 108 | ans[tx[i][0].id] = 1; | ^~ answer.code:109:55: error: ‘__gnu_cxx::__alloc_traits<std::allocator<coor>, coor>::value_type’ {aka ‘struct coor’} has no member named ‘id’ 109 | if(siz[i] != 1) ans[tx[i][siz[i] - 1].id] = 1; | ^~ answer.code: In function ‘int main()’: answer.code:141:71: error: expected primary-expression before ‘;’ token 141 | for(int i = 1; i <= n; i++) scanf("%d%d",&tower[i].x,&tower[i].y),; | ^ answer.code:140:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 140 | scanf("%d",&n); | ~~~~~^~~~~~~~~