제출 #1099373

#제출 시각아이디문제언어결과실행 시간메모리
1099373YFHHFYTracks in the Snow (BOI13_tracks)C++14
22.19 / 100
4 ms3936 KiB
#include<bits/stdc++.h> #define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long #define ld long double #define pb push_back // #define int long long #define itn int #define ss set <int> #define prq priority_queue <int> #define endl '\n' const ll MOD = 1e9 + 7; #define md(x) (((x%MOD)+MOD)%MOD) #define vi vector <int> #define vl vector<ll> #define str string #define mp make_pair #define mata int32_t #define sz size #define lc id *2 #define rc lc +1 #define SZ(x) (int)x.size() #define mid (l+r)/2 #define cn cin #define ct cout #define sep " " #define F first #define X first #define S second #define Y second using namespace std; typedef pair <int , int> pii; const ll maxn = 4e2 + 5 ; const int Lg = 23; const ll inf = 1e9; const int dx[] = {-1 , 0 , 1,0} , dy[] = {0,-1,0,1}; int n , m , d[maxn][maxn]; char a[maxn][maxn]; inline bool check (int x , int y){ return (1 <= x && x <= n && 1 <= y && y<= m); } void solve (){ cn >> n >> m; for (int i =1 ;i<= n ; i++){ cn >> a[i]+1; for (int j = 1 ; j <= m ; j++){ d[i][j] = inf; } } deque <pair <short ,short >> q; q.pb(mp(1,1)); d[1][1] = 1; while (SZ(q)){ int x = q.front().F , y = q.front().S; q.pop_front(); for (int i = 0 ; i < 4 ; i++){ int xx = x + dx[i]; int yy = y + dy[i]; if (check(xx , yy) && a[xx][yy] != '.'){ int val = d[x][y] + (a[x][y] != a[xx][yy]); if (d[xx][yy] > val){ d[xx][yy] = val; if (a[x][y] == a[xx][yy]){ q.push_front(mp(xx,yy)); } else{ q.pb(mp(xx,yy)); } } } } } int ans = 0; for (int i = 1 ; i<= n ; i++){ for (int j = 1 ; j <= m ; j++){ if (a[i][j] != '.'){ ans = max (ans , d[i][j]); } } } ct << ans << endl; } mata main(){ tizoboz; int tt = 1; // cn >> tt; while (tt--){ solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp: In function 'void solve()':
tracks.cpp:44:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   44 |         cn >> a[i]+1;
      |               ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...