QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#283340 | #3251. 数正方体 | iorit# | AC ✓ | 31ms | 4156kb | C++14 | 2.4kb | 2023-12-14 14:54:30 | 2023-12-14 14:54:31 |
Judging History
answer
#include <bits/stdc++.h>
#define LL long long
#define sl(n) strlen(n)
#define endline puts("")
#define pii pair<int , int>
#define pr_q priority_queue
#define debug puts("DEBUG.")
using namespace std;
const int N = 1e3 + 10;
const int inf = ~0u >> 2;
/*
..+---+
./ /|
+---+ |
| | +
| |/.
+---+..
*/
int n,m;
char s[N][N];
char bl[10][10] = {" ",
" ..+---+",
" ./ /|",
" +---+ |",
" | | +",
" | |/.",
" +---+.."};
char cl[10][10] = {" ",
" ..+---+",
" ./| |",
" + | |",
" | +---+",
" |/ /.",
" +---+.."};
// 6 行 7 列
queue<pii> q;
bool check(int x , int y)
{
if(x <= 0 || y <= 0 || x + 5 > n || y + 6 > m)
return 0;
bool fl = 1;
for(int i = 1;i <= 6;i++)
for(int j = 1;j <= 7;j++)
if(bl[i][j] != '.')
fl &= s[x + i - 1][y + j - 1] == bl[i][j];
return fl;
}
void clear(int x , int y)
{
for(int i = 1;i <= 6;i++)
for(int j = 1;j <= 7;j++)
if(cl[i][j] != '.')
s[x + i - 1][y + j - 1] = cl[i][j];
if( check(x , y - 4) )
q.push( pii(x , y - 4) );
if( check(x - 2 , y + 2) )
q.push( pii(x - 2 , y + 2) );
if( check(x + 3 , y) )
q.push( pii(x + 3 , y) );
}
void read(char *s)
{
int cnt = 0;
char ch = getchar();
while(ch == '\n' || ch == '\r')
ch = getchar();
while(ch != '\n' && ch != '\r')
s[cnt++] = ch,ch = getchar();
}
int main()
{
cin >> n >> m;
for(int i = 1;i <= n;i++)
read(s[i] + 1);
for(int i = 1;i <= n;i++)
for(int j = 1;j <= m;j++)
{
if( check(i , j) )
q.push( pii(i , j) );
}
int ans = 0;
while(!q.empty() )
{
pii v = q.front();
// cout << v.first << " " << v.second << endl;
q.pop();
clear(v.first , v.second);
++ans;
}
cout << ans << endl;
return 0;
}
/*
14 17
....+---+---+....
.../ / /|....
..+---+---+ |....
./ /| | +---+
+---+ | |/ /|
| | +---+---+ |
| |/ /| | +
+---+---+ | |/|
| | | +---+ |
| | |/ /| +
+---+---+---+ |/.
| | | | +..
| | | |/...
+---+---+---+....
*/
詳細信息
Test #1:
score: 100
Accepted
time: 13ms
memory: 4088kb
input:
371 259 ......................................................................+---+---+.................................................................................................................................................................................... ...................................
output:
84826
result:
ok single line: '84826'
Test #2:
score: 0
Accepted
time: 18ms
memory: 3948kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
128658
result:
ok single line: '128658'
Test #3:
score: 0
Accepted
time: 31ms
memory: 3900kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---...
output:
250000
result:
ok single line: '250000'
Test #4:
score: 0
Accepted
time: 20ms
memory: 4120kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................
output:
144484
result:
ok single line: '144484'
Test #5:
score: 0
Accepted
time: 12ms
memory: 4132kb
input:
395 235 ..............................................................................................+---+---+.................................................................................................................................... ...........................................................
output:
82548
result:
ok single line: '82548'
Test #6:
score: 0
Accepted
time: 17ms
memory: 3940kb
input:
401 301 ....................................................................................................+---+---+---+......................................................................................................................................................................................
output:
125068
result:
ok single line: '125068'
Test #7:
score: 0
Accepted
time: 12ms
memory: 4116kb
input:
367 259 ..................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+................................................................................................................................ ...................................
output:
80503
result:
ok single line: '80503'
Test #8:
score: 0
Accepted
time: 12ms
memory: 4012kb
input:
397 229 ................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+.................................................................... .................................................................
output:
82439
result:
ok single line: '82439'
Test #9:
score: 0
Accepted
time: 18ms
memory: 4156kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................
output:
127263
result:
ok single line: '127263'
Test #10:
score: 0
Accepted
time: 20ms
memory: 3868kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
151454
result:
ok single line: '151454'
Test #11:
score: 0
Accepted
time: 23ms
memory: 4152kb
input:
398 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+..........................................................................................................................................................
output:
182883
result:
ok single line: '182883'
Test #12:
score: 0
Accepted
time: 22ms
memory: 3992kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................
output:
209274
result:
ok single line: '209274'