CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:stpn129
Submission time:2022-10-31 10:13:44 +0200
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED28
#2ACCEPTED72
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2details
#2ACCEPTED0.00 s1, 2details
#3ACCEPTED0.00 s1, 2details
#4ACCEPTED0.00 s1, 2details
#5ACCEPTED0.00 s1, 2details
#6ACCEPTED0.00 s2details
#7ACCEPTED0.00 s2details
#8ACCEPTED0.00 s2details
#9ACCEPTED0.00 s2details

Code

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

void init_code() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
} 

void solve() {
  int n, m;
  cin >> n >> m;

  int ft = 0;
  pair<int, int> p = {0, 0};

  vector<vector<char>> a(n, vector<char> (m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      if (a[i][j] == '*' && !ft) {
        ft = 1;
        p = {i, j};
      }
    }
  }

  int x = 0;
  for (int i = p.first; i < n; ++i) {
    if (a[i][p.second] != '*') {
      break;
    }
    x++;
  }

  int y = 0;
  for (int j = p.second; j < m; ++j) {
    if (a[p.first][j] != '*') {
      break;
    }
    y++;
  }

  int res = 0;
  for (int i = p.first; i < p.first + x; ++i) {
    for (int j = p.second; j < p.second + y; ++j) {
      if (a[i][j] == '@') res++;
    }
  }
  cout << res << '\n';
}

signed main() {
  init_code();
  int t = 1;
  //cin >> t;
  while (t--) {
    solve();  
  }
  return 0;
}

/*


vector<pair<int, int>> moves = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  int n, m;
  cin >> n >> m;

  char x;
  pair<int,int> sa, sb;

  vector<vector<int>> a(n, vector<int> (m));
  for (int i = 0; i < n; ++i){
     for (int j = 0; j < m; ++j) {
       cin >> x;
       if (x == '#') { 
        a[i][j] = 0;
       } else if (x == '.'){
        a[i][j] = 1;
       } else if (x == 'A'){
        a[i][j] = 2;
        sa = {i, j};
       } else if (x == 'B'){
        a[i][j] = 3;
        sb = {i, j};
       }
     }
  }
  vector<vector<int>> used(n, vector<int> (m));
  used[sa.first][sa.second] = 1; used[sb.first][sb.second] = 2;
  
  set<pair<int, int>> q;
  q.insert(sa);

  pair<int, int> v;
  
  vector<pair<int, int>> 
  while (!q.empty()) {
    v = *q.begin();
    q.erase(q.begin());
    for (auto mv : moves) {
        int x = v.first + mv.first, y = v.second + mv.second;
        if (x >= 0 && x < n && y >= 0 && y < m && a[x][y] == 1 && used[x][y] == 0) {
          used[x][y] = 1;
          q.insert({x, y});
        }
    }
  }

  q.insert(sb);
  while (!q.empty()) {
    v = *q.begin();
    q.erase(q.begin());
    for (auto mv : moves) {
        int x = v.first + mv.first, y = v.second + mv.second;
        if (x >= 0 && x < n && y >= 0 && y < m && a[x][y] == 1 && used[x][y] == 0) {
          used[x][y] = 2;
          q.insert({x, y});
        } else if (x >= 0 && x < n && y >= 0 && y < m && a[x][y] == 1 && used[x][y] == 1) {
          cout << 1 << '\n';
          return;
        }
    }
  }

  for (int i = 0; i < ; ++i) {
    
  }
*/

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
3 3
***
*.*
***

correct output
0

user output
0

Test 2

Group: 1, 2

Verdict: ACCEPTED

input
3 3
***
*@*
***

correct output
1

user output
1

Test 3

Group: 1, 2

Verdict: ACCEPTED

input
5 10
...@......
..******..
@.*@@@@*.@
..******..
...

correct output
4

user output
4

Test 4

Group: 1, 2

Verdict: ACCEPTED

input
10 10
@@...@.@@@
..@@.@@..@
@.*******@
..*@....*.
...

correct output
11

user output
11

Test 5

Group: 1, 2

Verdict: ACCEPTED

input
10 10
**********
*@@@@@@@@*
*@@@@@@@@*
*@@@@@@@@*
...

correct output
64

user output
64

Test 6

Group: 2

Verdict: ACCEPTED

input
100 100
.........................@.......

correct output
60

user output
60

Test 7

Group: 2

Verdict: ACCEPTED

input
100 100
..@@..........@......@....@@.....

correct output
1507

user output
1507

Test 8

Group: 2

Verdict: ACCEPTED

input
100 100
.@..@@..@@.@..@..@..@@..@..@.....

correct output
3348

user output
3348

Test 9

Group: 2

Verdict: ACCEPTED

input
100 100
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...

correct output
7225

user output
7225