답안 #1109533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109533 2024-11-07T02:10:52 Z Ryu Pohlepko (COCI16_pohlepko) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define LL long long
 
#define rep(i, x) for(auto &i : (x))
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
#define left(x) ((x)<<1)
#define right(x) ((x)>>1)
#define LSOne(x) (x & -(x))
 
using namespace std;
using T = pair<pair<int,char>, pair<int, int>>;
 
const int SZ = 2e3 + 1;
const LL MOD = 1e9 + 7; 
const LL INF = 1e18 + 1;
 
LL bp (LL b, LL e, LL m = MOD) {
 if ( e == 0 ) return 1;
 LL T = bp(b, e / 2);
 T *= T; T %= m;
 if ( e & 1 ) T *= b;
 return T %= m;
}
 
LL nv_i (LL a) { return bp(a, MOD - 2); };
LL gcd (LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return (a * (b / gcd(a, b))); }
LL ceil (LL a, LL b) { return ((a + b - 1) / b); }
 
vector<vector<char>> G(SZ, vector<char> (SZ));
vector<vector<bool>> VIS(SZ, vector<bool> (SZ));
vector<char> LETTERS((SZ) * (SZ) + 1, 'z' + 1);
int n, m;

int bfs() {
  queue<T> Q;
  int d = 0;
  
  Q.push({{1, 'z' + 1}, {1, 1}});

  while(!Q.empty()) {
    int dist = Q.front().F.F, i = Q.front().S.F, j = Q.front().S.S, prev_l = Q.front().F.S;
    Q.pop();

    if(VIS[i][j] || i > n || j > m || LETTERS[dist - 1] != prev_l) continue;
    VIS[i][j] = 1;
    
    LETTERS[dist] = min(LETTERS[dist], G[i][j]);
    d = max(d, dist);
    Q.push({{dist + 1, G[i][j]}, {i + 1, j}});
    Q.push({{dist + 1, G[i][j]}, {i, j + 1}});
  }
  return d;
}

void solve() {
  cin >> n >> m;
 
  for(int i = 1; i <= n; i ++) {
    for(int j = 1; j <= m; j ++) {
      char x;
      cin >> x;
      
      G[i][j] = x;
    }
  } 

  int mx = bfs();

  for(int i = 1; i <= mx; i ++) {
    cout << LETTERS[i];
  }
}
 
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
 
  solve();
  return 0;
}

Compilation message

pohlepko.cpp:40:2: error: extended character   is not valid in an identifier
   40 |   queue<T> Q;
      |  ^
pohlepko.cpp:41:2: error: extended character   is not valid in an identifier
   41 |   int d = 0;
      |  ^
pohlepko.cpp:53:2: error: extended character   is not valid in an identifier
   53 |     d = max(d, dist);
      |  ^
pohlepko.cpp:53:5: error: extended character   is not valid in an identifier
   53 |     d = max(d, dist);
      |    ^
pohlepko.cpp:57:2: error: extended character   is not valid in an identifier
   57 |   return d;
      |  ^
pohlepko.cpp: In function 'int bfs()':
pohlepko.cpp:40:2: error: '\U000000a0queue' was not declared in this scope
   40 |   queue<T> Q;
      |  ^~~~~~
pohlepko.cpp:40:11: error: expected primary-expression before '>' token
   40 |   queue<T> Q;
      |          ^
pohlepko.cpp:40:13: error: 'Q' was not declared in this scope
   40 |   queue<T> Q;
      |            ^
pohlepko.cpp:41:2: error: '\U000000a0int' was not declared in this scope
   41 |   int d = 0;
      |  ^~~~
pohlepko.cpp:49:12: error: 'i' was not declared in this scope
   49 |     if(VIS[i][j] || i > n || j > m || LETTERS[dist - 1] != prev_l) continue;
      |            ^
pohlepko.cpp:49:15: error: 'j' was not declared in this scope
   49 |     if(VIS[i][j] || i > n || j > m || LETTERS[dist - 1] != prev_l) continue;
      |               ^
pohlepko.cpp:49:60: error: 'prev_l' was not declared in this scope
   49 |     if(VIS[i][j] || i > n || j > m || LETTERS[dist - 1] != prev_l) continue;
      |                                                            ^~~~~~
pohlepko.cpp:50:9: error: 'i' was not declared in this scope
   50 |     VIS[i][j] = 1;
      |         ^
pohlepko.cpp:50:12: error: 'j' was not declared in this scope
   50 |     VIS[i][j] = 1;
      |            ^
pohlepko.cpp:53:2: error: '\U000000a0' was not declared in this scope
   53 |     d = max(d, dist);
      |  ^
pohlepko.cpp:57:2: error: '\U000000a0return' was not declared in this scope; did you mean 'sigreturn'?
   57 |   return d;
      |  ^~~~~~~
      |  sigreturn
pohlepko.cpp:58:1: warning: no return statement in function returning non-void [-Wreturn-type]
   58 | }
      | ^