QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#534890#1127. Virus ExperimentWansur#0 3ms5980kbC++232.4kb2024-08-27 17:14:512024-08-27 17:14:51

Judging History

This is the latest submission verdict.

  • [2024-08-27 17:14:51]
  • Judged
  • Verdict: 0
  • Time: 3ms
  • Memory: 5980kb
  • [2024-08-27 17:14:51]
  • Submitted

answer

#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
#define int long long

using namespace std;
typedef long long ll;
const int maxn = 1e6 + 12;

int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
bool used[901][901];
int u[901][901];
int val[300], mx[10];
int n, m, k;

void solve(){
    string s;
    cin >> k >> n >> m;
    cin >> s;
    val['W'] = 0;
    val['E'] = 1;
    val['N'] = 2;
    val['S'] = 3;
    while(s.size() <= 1e5){
        s += s;
    }
    for(int mask = 0;mask < 16; mask++){
        for(int i=0;i<s.size();i++){
            if(!(mask & (1 << val[s[i]]))) continue;
            int j = i;
            while(j + 1 < s.size() && (mask & (1 << val[s[j+1]]))){
                j++;
            }
            val[mask] = max(val[mask], j - i + 1);
            i = j;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> u[i][j];
        }
    }
    int mx = 1e9, cnt = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(!u[i][j]) continue;
            queue<pair<int, int>> q;
            q.push({i, j});
            used[i][j] = 1;
            int s = 0;
            while(q.size()){
                auto [x, y] = q.front();
                q.pop();
                s++;
                for(int i=0;i<4;i++){
                    int x1 = x + dx[i], y1 = y + dy[i];
                    if(!used[x1][y1] && min(x1, y1) > 0 && x1 <= n && y1 <= m && u[x1][y1]){
                        int mask = 0;
                        for(int j=0;j<4;j++){
                            int x2 = x1 + dx[j], y2 = y1 + dy[j];
                            if(used[x2][y2]) mask |= (1 << j);
                        }
                        if(val[mask] >= u[x1][y1]){
                            used[x1][y1] = 1;
                            q.push({x1, y1});
                        }
                    }
                }
            }
            if(mx > s){
                mx = s;
                cnt = 0;
            }
            if(mx == s) cnt++;
            for(int x=1;x<=n;x++){
                for(int y=1;y<=m;y++){
                    used[x][y] = 0;
                }
            }
        }
    }
    cout << mx << ent << mx << ent;
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

53768 10 50
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

1
1

result:

wrong answer 2nd lines differ - expected: '10', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 3ms
memory: 5980kb

input:

10 10 10
NNNNSENESS
3 2 0 0 1 3 2 3 1 2
3 3 2 0 5 2 4 0 5 1
5 1 2 3 0 4 4 0 1 0
5 0 1 0 2 4 2 2 0 3
0 1 0 1 4 0 1 4 1 0
3 5 5 0 2 5 3 0 3 4
5 3 1 0 5 4 4 0 4 4
1 0 2 0 5 4 0 2 3 0
4 2 0 2 3 0 2 5 5 4
3 0 2 0 5 4 5 4 0 5

output:

1
1

result:

wrong answer 2nd lines differ - expected: '33', found: '1'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%