QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#90722 | #5101. Crystal Crosswind | _skb_ | WA | 0ms | 3516kb | C++17 | 3.9kb | 2023-03-24 22:59:30 | 2023-03-24 22:59:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
struct debug {
#define contPrint { *this << "["; \
int f = 0; for(auto it : x) { *this << (f?", ":""); *this << it; f = 1;} \
*this << "]"; return *this;}
~debug(){cerr << endl;}
template<class c> debug& operator<<(c x) {cerr << x; return *this;}
template<class c, class d>
debug& operator<<(pair<c, d> x) {*this << "(" << x.first << ", " << x.second << ")";
return *this;}
template<class c> debug& operator<<(vector<c> x) contPrint;
#undef contPrint
};
#define dbg(x) "[" << #x << ": " << x << "] "
#define Wa() cerr << "[LINE: " << __LINE__ << "] -> "; debug() <<
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
int dx, dy, k;
scanf("%d %d %d", &dx, &dy, &k);
int wind[k][2];
vector<pair<int, int>> B[k];
set<int> S[dx][dy];
for(int x = 0; x < dx; x++) {
for(int y = 0; y < dy; y++) {
for(int i = 0; i < k; i++) {
S[x][y].insert(i);
}
}
}
int ans[dy][dx]; // 1 -> molecule, 2 -> no molecule
memset(ans, 0, sizeof ans);
queue<pair<int, int>> Q;
queue<pair<int, int>> QN;
for(int i = 0; i < k; i++) {
scanf("%d %d", &wind[i][0], &wind[i][1]);
int b;
scanf("%d", &b);
for(int j = 0; j < b; j++) {
int x, y;
scanf("%d %d", &x, &y);
--x, --y;
B[i].push_back({x, y});
S[x][y].erase(i);
ans[y][x] = 1;
Q.push({x, y});
x -= wind[i][0];
y -= wind[i][1];
if(x >= 0 && x < dx && y >= 0 && y < dy) {
ans[y][x] = 2;
QN.push({x, y});
}
}
}
int vis[dx][dy];
memset(vis, 0, sizeof vis);
while(!Q.empty()) {
auto [x, y] = Q.front(); Q.pop();
vis[x][y] = 1;
ans[y][x] = 1;
for(int i : S[x][y]) {
int nx = x - wind[i][0];
int ny = y - wind[i][1];
if(nx >= 0 && nx < dx && ny >= 0 && ny < dy) {
assert(ans[ny][nx] != 2);
if(!vis[nx][ny]) {
vis[nx][ny] = 1;
Q.push({nx, ny});
}
}
}
}
for(int y = 0; y < dy; y++) {
for(int x = 0; x < dx; x++) {
if(ans[y][x] == 1) {
printf("#");
} else {
printf(".");
}
}
puts("");
}
puts("");
for(int x = 0; x < dx; x++) {
for(int y = 0; y < dy; y++) {
if(ans[y][x] == 0) {
for(int i = 0; i < k; i++) {
int nx = x - wind[i][0];
int ny = y - wind[i][1];
if(nx < 0 || nx >= dx || nx < 0 || ny >= dy) {
ans[y][x] = 2;
QN.push({x, y});
}
}
}
}
}
while(!QN.empty()) {
auto [x, y] = QN.front(); QN.pop();
for(int i = 0; i < k; i++) {
int nx = x + wind[i][0];
int ny = y + wind[i][1];
if(nx >= 0 && nx < dx && ny >= 0 && ny < dy) {
if(ans[ny][nx] == 0) {
ans[ny][nx] = 2;
QN.push({nx, ny});
}
}
}
}
for(int x = 0; x < dx; x++) {
for(int y = 0; y < dy; y++) {
if(ans[y][x] == 0) ans[y][x] = 1;
}
}
for(int y = 0; y < dy; y++) {
for(int x = 0; x < dx; x++) {
if(ans[y][x] == 1) {
printf("#");
} else {
printf(".");
}
}
puts("");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3516kb
input:
4 1 1 0 1 2 1 1 3 1
output:
#.#. ####
result:
wrong answer 3rd lines differ - expected: '#.#.', found: '####'