답안 #660933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660933 2022-11-23T14:55:19 Z activedeltorre 무지개나라 (APIO17_rainbow) C++14
0 / 100
2 ms 724 KB
#include <iostream>
#include <queue>
#include "rainbow.h"
using namespace std;
int sarpe[3][200005];
int sparsus[200005];
int sparjos[200005];
int spartot[200005];
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;
    }
    for(i=2; i<=c; i++)
    {
        if(sarpe[1][i]==0 && sarpe[1][i-1]==1)
        {
            sparsus[i]=sparsus[i-1]+1;
        }
        else
        {
            sparsus[i]=sparsus[i-1];
        }
    }
    for(i=2; i<=c; i++)
    {
        if(sarpe[2][i]==0 && sarpe[2][i-1]==1)
        {
            sparjos[i]=sparjos[i-1]+1;
        }
        else
        {
            sparjos[i]=sparjos[i-1];
        }
    }
    for(i=2; i<=c; i++)
    {
        if(sarpe[2][i]+sarpe[1][i]<=1 && sarpe[2][i-1]+sarpe[1][i-1]==2)
        {
            spartot[i]=spartot[i-1]+1;
        }
        else if(sarpe[2][i]==1 && sarpe[1][i]==0 && sarpe[2][i-1]==0 && sarpe[1][i-1]==1)
        {
            spartot[i]=spartot[i-1]+1;
        }
        else if(sarpe[2][i]==0 && sarpe[1][i]==1 && sarpe[2][i-1]==1 && sarpe[1][i-1]==0)
        {
            spartot[i]=spartot[i-1]+1;
        }
        else
        {
            spartot[i]=spartot[i-1];
        }
    }
}

int colour(int ar, int ac, int br, int bc)
{
    int i,j,nr=0;
    if(ar==1 && br==1)
    {
        if(sarpe[ar][ac]==0)
        {
            nr++;
        }
        return nr+sparsus[bc]-sparsus[ac];
    }
    else if(ar==2 && br==2)
    {
        if(sarpe[ar][ac]==0)
        {
            nr++;
        }
        return nr+sparjos[bc]-sparjos[ac];
    }
    else
    {
        if(sarpe[ac][ac]+sarpe[br][ac]==0)
        {
            nr++;
        }
        return nr+spartot[bc]-spartot[ac];
    }
}
/*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:12:11: warning: unused variable 'j' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |           ^
rainbow.cpp:12:13: warning: unused variable 'lin' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |             ^~~
rainbow.cpp:12:17: warning: unused variable 'col' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                 ^~~
rainbow.cpp:12:21: warning: unused variable 'sus' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                     ^~~
rainbow.cpp:12:25: warning: unused variable 'jos' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                         ^~~
rainbow.cpp:12:29: warning: unused variable 'st' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                             ^~
rainbow.cpp:12:32: warning: unused variable 'dr' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                ^~
rainbow.cpp:12:35: warning: unused variable 'poz1' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                   ^~~~
rainbow.cpp:12:40: warning: unused variable 'poz2' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                        ^~~~
rainbow.cpp:12:45: warning: unused variable 'grupe' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                             ^~~~~
rainbow.cpp:12:53: warning: unused variable 'z' [-Wunused-variable]
   12 |     int i,j,lin,col,sus,jos,st,dr,poz1,poz2,grupe=0,z;
      |                                                     ^
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:79:9: warning: unused variable 'i' [-Wunused-variable]
   79 |     int i,j,nr=0;
      |         ^
rainbow.cpp:79:11: warning: unused variable 'j' [-Wunused-variable]
   79 |     int i,j,nr=0;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -