QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601596#5270. Easily Distinguishable Trianglesship2077#RE 1ms4064kbC++231.1kb2024-09-30 08:46:482024-09-30 08:46:48

Judging History

你现在查看的是最新测评结果

  • [2024-09-30 08:46:48]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:4064kb
  • [2024-09-30 08:46:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=1005,mod=998244353;
string str[M],tmp[M];int n,ans=1;
void solve(){
    for (int i=1;i<=n;i++){
        int p=1;str[i][0]='.';
        for (int j=1;j<=n;j++)
            if (str[i][j]!='?'){
                int len=j-p;
                if (len){
                    int cnt0=str[i][p-1]=='#',
                        cnt1=str[i][j]=='#';
                    if (cnt0+cnt1==2) ans=0;
                    else if (cnt0+cnt1==1) ;
                    else ans=1ll*ans*(len+1)%mod;
                }
                p=j+1;
            }
        if (p<=n){
            if (str[i][p-1]=='.')
                ans=1ll*ans*(n-p+2)%mod;
        }
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>str[i],str[i]=" "+str[i];
    solve();
    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) tmp[i][j]=str[i][j];
    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) str[j][i]=tmp[i][j];
    solve();
    printf("%d\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3880kb

input:

2
.?
?#

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

3
#??
#??
?##

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

3
.#.
#?#
.#.

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

1
.

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

1
#

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

1
?

output:

4

result:

ok 1 number(s): "4"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

2
?.
?.

output:

12

result:

ok 1 number(s): "12"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

3
?.?
.#?
?.?

output:

256

result:

ok 1 number(s): "256"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

5
?????
.?.#.
???#?
?##??
?.?.?

output:

12288

result:

ok 1 number(s): "12288"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

10
...###???.
?.???.??#.
??.?????..
.#..?.????
???...?..?
.???.?..??
??.????.??
.????.?.??
#.????.?#?
?.##???#??

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

10
..?.??????
.?.?.?.?..
???#????.?
??#.??.??.
?..???.?#.
.????.?.??
?...?.#???
?.?..???.?
?.?..??.??
###..#.??#

output:

453983775

result:

ok 1 number(s): "453983775"

Test #12:

score: -100
Runtime Error

input:

100
.........?...........................................?...?.....?...................#??..??......?...
......?....................................?...?..?...?...?..??......?...?#......?............?.?.?.
.....??........??............?........?..............?...?..?.............................?......

output:


result: