답안 #660934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660934 2022-11-23T14:58:02 Z activedeltorre 무지개나라 (APIO17_rainbow) C++14
12 / 100
60 ms 7088 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=1;
        }
        return nr+sparsus[bc]-sparsus[ac];
    }
    else if(ar==2 && br==2)
    {
        if(sarpe[ar][ac]==0)
        {
            nr=1;
        }
        return nr+sparjos[bc]-sparjos[ac];
    }
    else
    {
        if(sarpe[ar][ac]+sarpe[br][ac]<=1)
        {
            nr=1;
        }
        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 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 51 ms 6396 KB Output is correct
4 Correct 52 ms 7088 KB Output is correct
5 Correct 51 ms 7032 KB Output is correct
6 Correct 57 ms 6636 KB Output is correct
7 Correct 48 ms 6712 KB Output is correct
8 Correct 49 ms 6252 KB Output is correct
9 Correct 49 ms 7064 KB Output is correct
10 Correct 52 ms 6940 KB Output is correct
11 Correct 55 ms 6616 KB Output is correct
12 Correct 45 ms 6608 KB Output is correct
13 Correct 48 ms 6972 KB Output is correct
14 Correct 48 ms 6988 KB Output is correct
15 Correct 47 ms 6684 KB Output is correct
16 Correct 60 ms 6576 KB Output is correct
# 결과 실행 시간 메모리 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 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -