QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#66047 | #5101. Crystal Crosswind | rumen_m# | WA | 5ms | 11524kb | C++14 | 2.4kb | 2022-12-06 02:02:00 | 2022-12-06 02:02:02 |
Judging History
answer
# include <bits/stdc++.h>
const long long MAXN = 1e6+5;
using namespace std;
int ans[1003][1003];
bool has[1003][1003][11];
int X[15],Y[15];
bool solved[1003][1003],solved2[1003][1003];
int n,m,k;
int countt[1003][1003];
bool valid(int x, int y)
{
if(x>0 && y > 0 && x <= n && y <= m)return true;
return false;
}
void dfs(int x, int y)
{
//cout<<x<<" "<<y<<endl;
if(solved[x][y])return ;
solved[x][y] = 1;
int t;
for(t= 1; t<=k; t++)
{
if(has[x][y][t])
{
int newx = x - X[t];
int newy = y - Y[t];
if(valid(newx,newy))
ans[newx][newy] = -1;
}
else
{
int newx = x - X[t];
int newy = y - Y[t];
if(valid(newx,newy))
{
// cout<< "("<<x<<","<<y<<")-> ("<<newx<<","<<newy<<")\n";
ans[newx][newy] = 1;
dfs(newx,newy);
}
}
}
}
void dfs2(int x, int y)
{
if(solved2[x][y])return ;
solved2[x][y] = 1;
for(int t = 1; t <= k; t++)
{
int newx = x + X[t];
int newy = y + Y[t];
if(valid(newx,newy) && ans[newx][newy] == 0)
{
countt[newx][newy]++;
if(countt[newx][newy] == k)
{
ans[newx][newy] = 2;
dfs2(newx,newy);
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>m>>k;
int i,j,x,y,wx,wy;
for(i = 1; i <= k; i++)
{
cin>>X[i]>>Y[i];
int b;
cin>>b;
for(j = 1;j <=b; j++)
{
cin>>x>>y;
has[x][y][i] = 1;
ans[x][y] = 1;
}
}
for(i = 1;i <= n; i++)
for(j = 1; j <= m; j++)
if(ans[i][j]==1)dfs(i,j);
for(i = 1;i <= n; i++)
for(j = 1; j <= m; j++)
if(ans[i][j])dfs2(i,j);
for(j = 1; j <= m; j++){
for(i = 1; i <= n; i++)
{
if(ans[i][j]==1)cout<<"#";
else
cout<<".";
}
cout<<endl;
}
cout<<endl;
for(j = 1; j <= m; j++){
for(i = 1; i <= n; i++)
{
if(ans[i][j] == 1 || ans[i][j] == 2) cout<<"#";
else
cout<<".";
}
cout<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 9408kb
input:
4 1 1 0 1 2 1 1 3 1
output:
#.#. #.#.
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 9416kb
input:
4 4 2 1 0 4 2 4 2 1 1 3 1 2 -1 0 4 4 3 4 2 3 1 3 4
output:
.##. #### #### .##. .##. #### #### .##.
result:
ok 9 lines
Test #3:
score: 0
Accepted
time: 2ms
memory: 9448kb
input:
8 12 1 -1 -4 10 5 7 2 4 1 5 5 11 1 6 5 3 8 11 5 1 1 4 7 3
output:
....#... ........ ....#.#. ##...... #....... #....... ....#... ........ ........ ........ ....#..# ........ ....#... ........ ..#####. ##...... #....... #....... ...##.#. ........ ........ ........ ....#..# ........
result:
ok 25 lines
Test #4:
score: 0
Accepted
time: 2ms
memory: 9428kb
input:
4 4 2 1 0 6 2 1 1 2 1 3 4 3 2 4 4 2 -1 0 6 4 2 2 2 2 3 3 1 3 4 4 3
output:
.##. ##.# ##.# .##. .##. ##.# ##.# .##.
result:
ok 9 lines
Test #5:
score: 0
Accepted
time: 2ms
memory: 9512kb
input:
8 10 1 -6 -6 25 7 3 8 5 8 6 4 5 4 4 3 2 5 3 6 8 5 4 1 9 1 8 7 10 8 4 2 7 3 9 2 4 3 10 4 6 2 10 3 6 8 8 6 10 4 3 6 1 7 9
output:
.....#.. ..#..... ...##.#. .#.##..# ...#...# ..##...# .#...... #....#.# #.#...#. .##..##. .....#.. .##..... #..##.#. ##.##..# ...#...# ..##...# .#...... #....#.# #.#...#. .##..##.
result:
ok 21 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 9580kb
input:
30 25 2 9 -15 229 27 8 13 20 25 20 15 9 7 16 23 4 2 18 20 21 21 24 19 24 2 23 19 18 25 7 11 6 7 5 4 12 15 25 13 1 28 20 9 1 8 8 17 21 3 1 21 20 14 20 1 12 14 16 9 5 19 17 7 24 11 20 15 18 15 11 28 12 9 15 19 20 30 15 4 17 10 13 4 9 20 24 2 24 13 9 20 25 25 24 11 14 20 19 24 12 9 9 3 5 27 14 19 12 12...
output:
..##...##..##....####.....##.. ..........###............#.... .......###.##.#.#.....##..##.# ...###.....#..#.....#.#...#.#. #.##..#.#.#...#.......#..#.#.. #.........#........##..#..#... ...#....#.#....#.##.....#..#.. .......##...##.#..#.#.#..##.#. ...#....#####.#.....##.###.... .#..##.......#...##.#...
result:
ok 51 lines
Test #7:
score: -100
Wrong Answer
time: 5ms
memory: 11524kb
input:
20 20 3 -4 -3 53 18 20 2 10 7 5 17 18 14 6 14 8 13 19 9 18 17 16 20 15 3 20 7 2 8 7 17 6 1 19 20 7 7 6 13 1 18 16 19 14 8 8 19 20 8 20 7 18 2 9 1 4 16 20 2 17 19 19 15 13 20 12 18 10 20 19 8 12 17 13 17 10 18 18 12 19 9 19 20 3 20 4 1 20 20 6 8 5 19 18 17 17 20 16 16 7 19 17 18 14 2 1 19 6 18 8 -12 ...
output:
.#.....#...##....... ......#..#.......... ...#........#.#....# #..........#...#...# ......##.....#...... ......##.....#..#.## .....#.#.......#...# .......#.#...#...#.. .#.##......#........ .#.....#.#......##.. ......#.#.#..#...... .......##......#...# ...#......#####.#... .......#..#.#.#..##. ..#......
result:
wrong answer 34th lines differ - expected: '...#......#####.#...', found: '...##.....#####.#...'