QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357355#404. Solitaireearlyamazon10 54ms4200kbC++141.2kb2024-03-18 20:37:022024-03-18 20:37:04

Judging History

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

  • [2024-03-18 20:37:04]
  • 评测
  • 测评结果:10
  • 用时:54ms
  • 内存:4200kb
  • [2024-03-18 20:37:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int mod = 1e9+7;
const int mn = 2003;
int n;
char t[5][mn];
int dp[1<<20];
vector<pair<int,int>> puste;

bool czy(int msk, int i, int j){
    for (int k = 0; k < puste.size(); k++){
        if (msk&(1<<k)){
            t[puste[k].first][puste[k].second] = 'o';
        }
    }
    bool wyn = 0;
    if ((t[i-1][j] == 'o' && t[i+1][j] == 'o') || (t[i][j-1] == 'o' && t[i][j+1] == 'o')) wyn = 1;
    for (int k = 0; k < puste.size(); k++){
        if (msk&(1<<k)){
            t[puste[k].first][puste[k].second] = 'x';
        }
    }
    return wyn;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i = 1; i <= 3; i++){
        for (int j = 1; j <= n; j++){
            cin>>t[i][j];
            if (t[i][j] == 'x') puste.push_back({i, j});
        }
    }
    dp[0] = 1;
    for (int i = 1; i < (1<<puste.size()); i++){
        for (int j = 0; j < puste.size(); j++){
            if (i&(1<<j) && czy(i-(1<<j), puste[j].first, puste[j].second)) dp[i] = (dp[i] + dp[i-(1<<j)])%mod;
        }
    }
    cout<<dp[(1<<puste.size())-1]<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 3ms
memory: 3648kb

input:

21
ooooxoooooxoooooxoooo
oooxooooooooxxxxxooxo
ooxooooooooooooooooxo

output:

319334400

result:

ok single line: '319334400'

Test #2:

score: 0
Accepted
time: 19ms
memory: 3876kb

input:

27
oxoooxooooooooooooooooooooo
ooooooxxxxoooooxoxooooxoooo
oooxooxooxoooxoooxoooooxooo

output:

188603933

result:

ok single line: '188603933'

Test #3:

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

input:

20
oooooooooxooooxoooxo
oxoxoooooooxooooooxo
ooooooooxooooooooooo

output:

40320

result:

ok single line: '40320'

Test #4:

score: 0
Accepted
time: 51ms
memory: 4084kb

input:

13
ooxoxoxooxooo
xoxxxoxxxooxo
ooooxoxoxoxoo

output:

22599513

result:

ok single line: '22599513'

Test #5:

score: 0
Accepted
time: 51ms
memory: 4200kb

input:

13
oxoxooxooxooo
xooxxxxoxoxxx
ooxooooxoxooo

output:

17662907

result:

ok single line: '17662907'

Test #6:

score: 0
Accepted
time: 47ms
memory: 4132kb

input:

11
oxoxoxoxoxo
xxxxoxoxoxo
oxoxoxooxoo

output:

891195994

result:

ok single line: '891195994'

Test #7:

score: 0
Accepted
time: 51ms
memory: 4188kb

input:

14
ooxoooxoxoooxo
xoxxooooxxxoxx
oooxoxooooxoxo

output:

549439514

result:

ok single line: '549439514'

Test #8:

score: 0
Accepted
time: 47ms
memory: 4140kb

input:

14
ooxoooooxooxoo
xxxxxxoxxoxoox
oxoooooxoxoooo

output:

278974156

result:

ok single line: '278974156'

Test #9:

score: 0
Accepted
time: 51ms
memory: 4132kb

input:

11
ooxooxoxoxo
xxxxxoooxox
oxoxoxoxoxo

output:

591208466

result:

ok single line: '591208466'

Test #10:

score: 0
Accepted
time: 51ms
memory: 4084kb

input:

11
ooxoxoxooxo
xxoooxxxxxx
ooxoxoxoxoo

output:

966753075

result:

ok single line: '966753075'

Test #11:

score: 0
Accepted
time: 50ms
memory: 4140kb

input:

15
oooxooooxooxooo
oxooxxoooxxxxxx
ooooxoxoooxoxoo

output:

727472313

result:

ok single line: '727472313'

Test #12:

score: 0
Accepted
time: 54ms
memory: 4128kb

input:

10
oxoxooxooo
xxxxxoxxxx
oxoxoxoxoo

output:

377955629

result:

ok single line: '377955629'

Subtask #2:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 2ms
memory: 3624kb

input:

880
ooxooooooxoxoooxoxoooooxooxooooxoxooooooooooooooxooooooxoxooooxooooxoxooooooxoxooooooooooxoxooooxooxooxoooooooooooxoxoooooxoooooxoxoxooxoooxooxooooxooooxoxoxoooxoooooxoooxooxoxoooooooxooooxooooooxooooxoxooxoooooxoxooooxooxooooooooooooooxoooooooooooxooooooooooooooxooooxoxoxooooooxooooooooxooooxoo...

output:

14241407

result:

wrong answer 1st lines differ - expected: '934647418', found: '14241407'

Subtask #3:

score: 0
Runtime Error

Test #38:

score: 0
Runtime Error

input:

27
oxooooxooooooxoooxoooooxoxo
xxooxooooxxxoxoooxooxxxxxoo
ooxoxoxoxoooxoxooooxoxooxoo

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%