답안 #660919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660919 2022-11-23T14:27:10 Z activedeltorre 무지개나라 (APIO17_rainbow) C++14
11 / 100
3000 ms 8384 KB
#include <iostream>
#include <queue>
#include "rainbow.h"
using namespace std;
int sarpe[1005][1005];
int fre[1005][1005];
int dx[10]={0,0,0,-1,1};
int dy[10]={0,1,-1,0,0};
queue <pair<int,int> >qu;
int  n,m;
void init(int r, int c, int x, int y, int m, char *s)
{
    int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
    sarpe[x][y]=1;
    for(i=0;i<=m;i++)
    {
        if(s[i]=='N')
        {
            x--;
        }
        if(s[i]=='S')
        {
            x++;
        }
        if(s[i]=='W')
        {
            y--;
        }
        if(s[i]=='E')
        {
            y++;
        }
        sarpe[x][y]=1;
    }
}

int colour(int ar, int ac, int br, int bc)
{
    int i,j,grupe=0,lin,col,poz1,poz2,z;
    for(i=ar;i<=br;i++)
    {
        for(j=ac;j<=bc;j++)
        {
            fre[i][j]=0;
        }
    }
    for(i=ar;i<=br;i++)
    {
        for(j=ac;j<=bc;j++)
        {
            if(fre[i][j]==0 && sarpe[i][j]==0)
            {
                grupe++;
                fre[i][j]=1;
                qu.push({i,j});
                while(qu.size())
                {
                    lin=qu.front().first;
                    col=qu.front().second;
                    qu.pop();
                    for(z=1;z<=4;z++)
                    {
                        poz1=lin+dx[z];
                        poz2=col+dy[z];
                        if(poz1>=ar && poz2>=ac && poz1<=br && poz2<=bc && fre[poz1][poz2]==0 && sarpe[poz1][poz2]==0)
                        {
                            fre[poz1][poz2]=1;
                            qu.push({poz1,poz2});
                        }
                    }
                }
            }
        }
    }
    return grupe;
}/*
static int R, C, M, Q;
static int sr, sc;
static char S[1000 + 5];

int main()
{
    cin>>R>>C>>M>>Q;
    cin>>sr>>sc;
    if (M > 0)
    {
        cin>>S;
    }
    init(R, C, sr, sc, M, S);
    int query;
    for (query = 0; query < Q; query++)
    {
        int ar, ac, br, bc;
        cin>>ar>>ac>>br>>bc;
        cout<<colour(ar, ac, br, bc)<<'\n';
    }

    return 0;
}*/

Compilation message

rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:13:11: warning: unused variable 'j' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |           ^
rainbow.cpp:13:13: warning: unused variable 'lin' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |             ^~~
rainbow.cpp:13:17: warning: unused variable 'col' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                 ^~~
rainbow.cpp:13:21: warning: unused variable 'sus' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                     ^~~
rainbow.cpp:13:25: warning: unused variable 'jos' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                         ^~~
rainbow.cpp:13:29: warning: unused variable 'st' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                             ^~
rainbow.cpp:13:32: warning: unused variable 'dr' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                ^~
rainbow.cpp:13:35: warning: unused variable 'poz1' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                   ^~~~
rainbow.cpp:13:40: warning: unused variable 'poz2' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                        ^~~~
rainbow.cpp:13:45: warning: unused variable 'grupe' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                             ^~~~~
rainbow.cpp:13:53: warning: unused variable 'z' [-Wunused-variable]
   13 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 7 ms 708 KB Output is correct
3 Correct 13 ms 596 KB Output is correct
4 Correct 17 ms 596 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 12 ms 668 KB Output is correct
12 Correct 9 ms 596 KB Output is correct
13 Correct 8 ms 716 KB Output is correct
14 Correct 6 ms 596 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 3078 ms 1516 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 7 ms 708 KB Output is correct
3 Correct 13 ms 596 KB Output is correct
4 Correct 17 ms 596 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 12 ms 668 KB Output is correct
12 Correct 9 ms 596 KB Output is correct
13 Correct 8 ms 716 KB Output is correct
14 Correct 6 ms 596 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Execution timed out 3079 ms 8384 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 7 ms 708 KB Output is correct
3 Correct 13 ms 596 KB Output is correct
4 Correct 17 ms 596 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 12 ms 668 KB Output is correct
12 Correct 9 ms 596 KB Output is correct
13 Correct 8 ms 716 KB Output is correct
14 Correct 6 ms 596 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Execution timed out 3079 ms 8384 KB Time limit exceeded
19 Halted 0 ms 0 KB -