답안 #491265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491265 2021-12-01T09:04:48 Z ktkerem Zoo (COCI19_zoo) C++17
110 / 110
51 ms 10256 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll _i=0;
#define ffn(x) _i=x
#define llll pair<ll , ll>
#define stitr set<llll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
const ll limit = 1e9+7; 
const ll ous=1e5 + 5;
const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1};
ll vis[1005][1005];
void solve(){
    ll n ,m ;cin >> n >> m;
    string h[n];
    fora(i,n){
        cin >> h[i];
    }
    ll ans = 0;
    stack<llll> st;
    st.push({(n-1) , (m-1)});
    while(!st.empty()){
        vector<llll> ko;
        ans++;
        char  o = h[st.top().fi][st.top().sec];
        while(!st.empty()){
            llll a= st.top();
            st.pop();
            vis[a.fi][a.sec] = 1;
            fora(i , 4){
                if(n>a.fi + dx[i] && 0<= a.fi + dx[i] && m> a.sec + dy[i] && 0 <= a.sec + dy[i] && vis[a.fi + dx[i]][a.sec + dy[i]] == 0 && h[a.fi + dx[i]][a.sec + dy[i]] != '*'){
                    if(h[a.fi + dx[i]][a.sec + dy[i]] != o){
                        ko.pb({a.fi + dx[i] , a.sec + dy[i]});
                        vis[a.fi + dx[i]][a.sec + dy[i]] = 2;
                    }
                    else{
                        vis[a.fi + dx[i]][a.sec + dy[i]] = 1;
                        st.push({a.fi + dx[i] , a.sec + dy[i]});   
                    }
                }
            }
        }
        fora(i , ko.size()){
            st.push({ko[i].fi , ko[i].sec});
        }
    }
    cout << ans << "\n";
    return;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0; 
} 

Compilation message

zoo.cpp: In function 'void solve()':
zoo.cpp:9:32: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
    9 | #define fora(y,x) for(ll y=_i;x>y;y++)
......
   49 |         fora(i , ko.size()){
      |                                 
zoo.cpp:49:9: note: in expansion of macro 'fora'
   49 |         fora(i , ko.size()){
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 712 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 712 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 9 ms 7864 KB Output is correct
17 Correct 9 ms 8004 KB Output is correct
18 Correct 8 ms 7880 KB Output is correct
19 Correct 11 ms 8648 KB Output is correct
20 Correct 9 ms 7856 KB Output is correct
21 Correct 43 ms 9804 KB Output is correct
22 Correct 47 ms 9716 KB Output is correct
23 Correct 45 ms 9796 KB Output is correct
24 Correct 46 ms 10200 KB Output is correct
25 Correct 47 ms 10188 KB Output is correct
26 Correct 44 ms 9856 KB Output is correct
27 Correct 48 ms 9840 KB Output is correct
28 Correct 44 ms 9740 KB Output is correct
29 Correct 51 ms 10256 KB Output is correct
30 Correct 44 ms 10020 KB Output is correct