답안 #467339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467339 2021-08-22T16:43:41 Z TlenekWodoru Game (eJOI20_game) C++14
20 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
int tab[100][100][5];
bool zaj[100][100];
int h=0;
void DFS(int y, int x)
{
    zaj[y][x]=1;
    if(tab[y][x][1]==0&&zaj[y-1][x]==0)
    {
        DFS(y-1,x);
    }
    if(tab[y][x][2]==0&&zaj[y][x+1]==0)
    {
        DFS(y,x+1);
    }
    if(tab[y][x][3]==0&&zaj[y+1][x]==0)
    {
        DFS(y+1,x);
    }
    if(tab[y][x][4]==0&&zaj[y][x-1]==0)
    {
        DFS(y,x-1);
    }
    h++;
}
int main()
{ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;cin>>n>>m;
    for(int i=0;i<=n+1;i++)
    {
        zaj[i][0]=1;
        zaj[i][m+1]=1;
    }
    for(int i=0;i<=n+1;i++)
    {
        zaj[0][i]=1;
        zaj[n+1][i]=1;
    }
    for(int i=1;i<=n+1;i++)
    {
        string A;
        cin>>A;
        for(int j=0;j<A.size();j++)
        {
            tab[i][j+1][1]=A[j]-48;
            tab[i-1][j+1][3]=A[j]-48;
        }
    }
    for(int i=1;i<=n;i++)
    {
        string A;
        cin>>A;
        for(int j=0;j<A.size();j++)
        {
            tab[i][j+1][4]=A[j]-48;
            tab[i][j][2]=A[j]-48;
        }
    }
///-=-==-==--==-=-==-==-==-==============-==-===--===--==-===-===
    /**for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<"{"<<tab[i][j][1]<<","<<tab[i][j][2]<<","<<tab[i][j][3]<<","<<tab[i][j][4]<<"} ";
        }
        cout<<endl;
    }**/
///-=-=--==-==-==-=-==-==-==-=-==-==-==-=-==-==-==-==-==-==-=-==-==-=-==--==-=-=-=
    vector<int>U;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(zaj[i][j]==0&&(tab[i][j][1]==0||tab[i][j][2]==0||tab[i][j][3]==0))
            {
                h=0;
                DFS(i,j);
                U.push_back(h);
            }
        }
    }
    sort(U.begin(),U.end());
    int wynik=0;
    for(int i=0;i<U.size();i++)
    {
        if(i%2==0)
        {
            wynik-=U[i];
        }
        else
        {
            wynik+=U[i];
        }
    }
    cout<<wynik<<endl;
    return 0;
}





Compilation message

game.cpp: In function 'int main()':
game.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(int j=0;j<A.size();j++)
      |                     ~^~~~~~~~~
game.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j=0;j<A.size();j++)
      |                     ~^~~~~~~~~
game.cpp:85:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for(int i=0;i<U.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 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 332 KB Output is correct
5 Incorrect 0 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Incorrect 0 ms 316 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Incorrect 0 ms 332 KB Output isn't correct
14 Halted 0 ms 0 KB -