QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#571623 | #3125. Dango Maker | ivan_alexeev | 13 | 0ms | 3880kb | C++23 | 2.9kb | 2024-09-18 01:39:08 | 2024-09-18 01:39:08 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#ifdef lisie_bimbi
#else
#define endl '\n'
#endif
typedef long long ll;
const ll inf = 1'000'000'000'000'000'000;
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,bmi2,fma,popcnt")
//#define int long long
int n, m;
vector<vector<int>> z;
bool get(int x, int y, bool f){
if((x >= 0) && (x < n) && (y >= 0) && (y < m)){
}else{
return 0;
}
if(f){
if(x + 2 < n){
return ((z[x][y] == 0) && (z[x + 1][y] == 1) && (z[x + 2][y] == 2));
}else{
return 0;
}
}else{
if(y + 2 < m){
return ((z[x][y] == 0) && (z[x][y + 1] == 1) && (z[x][y + 2] == 2));
}else{
return 0;
}
}
}
vector<vector<int>> v;
int kl(int a, int b){
return a * m + b;
}
vector<int> used;
int lox[2];
void dfs(int u, int type){
lox[type]++;
used[u] = 1;
for(auto i : v[u]){
if(!used[i]){
dfs(i, type ^ 1);
}
}
}
void solve(){
cin >> n >> m;
z.resize(n, vector<int>(m));
for(int i = 0; i < n; i++){
string s;
cin >> s;
for(int j = 0; j < m; j++){
if(s[j] == 'R'){
z[i][j] = 0;
}else if(s[j] == 'G'){
z[i][j] = 1;
}else{
z[i][j] = 2;
}
}
}
v.resize(n * m * 2);
vector<int> h(n * m * 2);
for(int x = 0; x < n; x++){
for(int y = 0; y < m; y++){
if(get(x, y, 1)){
h[kl(x, y)] = 1;
for(int k = 0; k < 3; k++){
if(get(x + k, y - k, 0)){
v[kl(x, y)].push_back(kl(x + k, y - k) + n * m);
}
}
}
}
}
for(int x = 0; x < n; x++){
for(int y = 0; y < m; y++){
if(get(x, y, 0)){
h[kl(x, y) + n * m] = 1;
for(int k = 0; k < 3; k++){
if(get(x - k, y + k, 1)){
v[kl(x, y) + n * m].push_back(kl(x - k, y + k));
}
}
}
}
}
used.resize(n * m * 2);
int ans = 0;
for(int i = 0; i < n * m * 2; i++){
if(h[i] && !used[i]){
lox[0] = 0;
lox[1] = 0;
dfs(i, 0);
ans += max(lox[0], lox[1]);
}
}
cout << ans << endl;
}
signed main(){
#ifdef lisie_bimbi
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
cin.tie(nullptr)->sync_with_stdio(false);
#endif
cout << setprecision(5) << fixed;
int _ = 1;
//cin >> t;
while(_--){
solve();
}
return 0;
}
詳細信息
Subtask #1:
score: 13
Accepted
Test #1:
score: 13
Accepted
time: 0ms
memory: 3672kb
input:
1 1 G
output:
0
result:
ok single line: '0'
Test #2:
score: 13
Accepted
time: 0ms
memory: 3636kb
input:
1 2 RG
output:
0
result:
ok single line: '0'
Test #3:
score: 13
Accepted
time: 0ms
memory: 3796kb
input:
2 1 W R
output:
0
result:
ok single line: '0'
Test #4:
score: 13
Accepted
time: 0ms
memory: 3640kb
input:
3 2 WW RW WR
output:
0
result:
ok single line: '0'
Test #5:
score: 13
Accepted
time: 0ms
memory: 3804kb
input:
4 4 GRRW GWWR WWWW RGRG
output:
0
result:
ok single line: '0'
Test #6:
score: 13
Accepted
time: 0ms
memory: 3636kb
input:
4 4 RGRR RRRG GRGW RGWW
output:
2
result:
ok single line: '2'
Test #7:
score: 13
Accepted
time: 0ms
memory: 3572kb
input:
4 4 RRGR GRRG WRGW RGWW
output:
3
result:
ok single line: '3'
Test #8:
score: 13
Accepted
time: 0ms
memory: 3868kb
input:
4 4 RGWR GGGW WWGW RWGW
output:
1
result:
ok single line: '1'
Test #9:
score: 13
Accepted
time: 0ms
memory: 3628kb
input:
3 3 RGW GGG WGW
output:
1
result:
ok single line: '1'
Test #10:
score: 13
Accepted
time: 0ms
memory: 3632kb
input:
4 1 W R G W
output:
1
result:
ok single line: '1'
Test #11:
score: 13
Accepted
time: 0ms
memory: 3632kb
input:
4 4 RGWR GWRG WRGW RGWR
output:
3
result:
ok single line: '3'
Test #12:
score: 13
Accepted
time: 0ms
memory: 3576kb
input:
4 4 RWWR GWRG WGGW RGWR
output:
3
result:
ok single line: '3'
Test #13:
score: 13
Accepted
time: 0ms
memory: 3604kb
input:
4 4 RGWR WWRG WRGW RWGR
output:
2
result:
ok single line: '2'
Test #14:
score: 13
Accepted
time: 0ms
memory: 3564kb
input:
4 4 RRRR GGGG WWWW RRRR
output:
4
result:
ok single line: '4'
Test #15:
score: 13
Accepted
time: 0ms
memory: 3580kb
input:
4 4 RRRR GGGR WWWW RRRR
output:
3
result:
ok single line: '3'
Test #16:
score: 13
Accepted
time: 0ms
memory: 3628kb
input:
4 4 RRRR GGGG WWWW RWRR
output:
4
result:
ok single line: '4'
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #17:
score: 20
Accepted
time: 0ms
memory: 3644kb
input:
5 5 RRGRR RGRGW RRWRW RGWGW RWWWW
output:
3
result:
ok single line: '3'
Test #18:
score: 20
Accepted
time: 0ms
memory: 3632kb
input:
6 6 RGWRGW RRRGWR RRWGWR WRRRWG GGGGGW WWWWWW
output:
7
result:
ok single line: '7'
Test #19:
score: 20
Accepted
time: 0ms
memory: 3576kb
input:
7 10 RRRGRGWRGW RGGGWRRGWR RWWWWGRRGG RGWRWWGGGW WWRGWRGWGW RGWWGGRGWW RRGWWWWWWW
output:
14
result:
ok single line: '14'
Test #20:
score: 20
Accepted
time: 0ms
memory: 3648kb
input:
10 8 RGWRRRGW RGWGRRGW WRGWGRGW RGWWRGWW GWRRGWWW WRRGRWRR GRGWGRGG WGWWWRWR RGWRGRGW RRWRGWWW
output:
16
result:
ok single line: '16'
Test #21:
score: 20
Accepted
time: 0ms
memory: 3604kb
input:
10 10 RRRRGWRRGW GRGRGRGGRR RGRGWGRRGR RWWWRRGRGW GRGGGRGWGG WRGWWGGRGW GGGRWWWRRR WWGRGWRRGG WWGWGWGGWW RRGWGRWWWW
output:
16
result:
ok single line: '16'
Test #22:
score: 20
Accepted
time: 0ms
memory: 3804kb
input:
10 10 RRRWRGWRGW GGGGGGRRWG WGWRWWGGGW RRRRRRWRRG GGGGGGRGGR WGWWWWGWGW WRRGWRWRGW RGWGRGWGRW GRWRGWWWGG RGWWGWRGWW
output:
19
result:
ok single line: '19'
Test #23:
score: 20
Accepted
time: 0ms
memory: 3756kb
input:
10 10 WGWGRWWGWR RGGWGRWWGR GWRRRRWWWG RGWRGWRRRG GRRWWGGRGG GGGGRWGRGG RRRGWWWWRW WRRRWRGRGR RGWGRWGRWG WRRWGGGWWW
output:
7
result:
ok single line: '7'
Test #24:
score: 20
Accepted
time: 0ms
memory: 3580kb
input:
10 10 GGRRGRGRWR RRWRGWWRRW WGRWWRRRWG GGWWRWGRGR RGGGRRGWRR WRWWWRWWWW WRWGGGGRRR RWGRGRWGGW GWGWWGWGRR GRWGGGWRWW
output:
2
result:
ok single line: '2'
Test #25:
score: 20
Accepted
time: 0ms
memory: 3572kb
input:
10 1 R G R W G G G R G R
output:
0
result:
ok single line: '0'
Test #26:
score: 20
Accepted
time: 0ms
memory: 3648kb
input:
1 10 GGGRWWGGWW
output:
0
result:
ok single line: '0'
Test #27:
score: 20
Accepted
time: 0ms
memory: 3648kb
input:
10 10 RGWRGWRGWR GWRGWRGWRG WRGWRGWRGW RGWRGWRGWR GWRGWRGWRG WRGWRGWRGW RGWRRWRGWR GWRGWRGWRG WRGWRGWRGW RGWRGWRGWR
output:
27
result:
ok single line: '27'
Test #28:
score: 20
Accepted
time: 0ms
memory: 3580kb
input:
10 10 RGWRGWRGWR GWRGWRGWRG WRGWRGWRGW RGWRGWRGWR GWRWWRGWRG WRGWRGWRGW RGWRGWRGWR GWRWWRGWRG RRGWRGWRGW RGWRGWRGWW
output:
26
result:
ok single line: '26'
Test #29:
score: 20
Accepted
time: 0ms
memory: 3580kb
input:
10 10 RGGRGWGGWR GGRGWRWWRG WRGWRGWRGW GGWGWWRGWR RWRGWRGWRG WRGWRGWRGW RGWRGWRGWR GWWGWRGRRG WRGWRGGRGW RGWRGRRGWR
output:
20
result:
ok single line: '20'
Test #30:
score: 20
Accepted
time: 0ms
memory: 3640kb
input:
10 10 RRRRRRRRRR GGWGGGGGGG WWWWWWWWWW RRRRRRRRRR GGGGGGGGGG WWWWWWWGWW RRRRRRRRRR GGGGGGGGGG WWWWWWWWWW RRRRRRRRRR
output:
28
result:
ok single line: '28'
Test #31:
score: 20
Accepted
time: 0ms
memory: 3880kb
input:
10 10 RRGRRRWRRR GGGGGGGGRG WWWGWWWWWW RRRRRRRRRR GGGGGGGGGG WGRWWWWWWW RRRRRRRRRR GGGGGGGGGG WWWWWWWWWW RRRRRRRRRR
output:
24
result:
ok single line: '24'
Test #32:
score: 20
Accepted
time: 0ms
memory: 3580kb
input:
10 10 RGRRRRRGRR GGGGWGGGGG GWWWWWWRWW RRRRWRRRRR GGGGGGGGGG WWWWWWWWRW RRRRRRRRRR GGGGGWGGGG GWGWWWWGWW RWRRRRRRWW
output:
20
result:
ok single line: '20'
Test #33:
score: 20
Accepted
time: 0ms
memory: 3620kb
input:
10 10 RGWRGWRGWR GWRGWRGWRG WRGWRGWRGW RGWRGWRGWR GWRGWRGWRG WRGWRGWRGW RGWRGGRGWR GWRGWRGWRG WRGWRGWRGW RGWRGWRGWR
output:
26
result:
ok single line: '26'
Test #34:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
10 10 RGWRGWRGWR WWRGWRGWRG WRGWRGWRGW RGWRGWRGWR GWRGWWGWRG WRGWRGWRGW RGWRGWRGWR GWRGWRGWRG WRGWRGWRGW RGWRGWRGWR
output:
26
result:
wrong answer 1st lines differ - expected: '27', found: '26'
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%