답안 #100417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100417 2019-03-11T05:48:29 Z AbduM 무지개나라 (APIO17_rainbow) C++14
11 / 100
3000 ms 23560 KB
#include <bits/stdc++.h>
#ifdef ioi
    //#include "rainbow.h"
#else
    #include "rainbow.h"
#endif // ioi

#define sz(s)                   (ll)(s.size())
#define all(x)                  (x.begin(), x.end())
#define pb                      push_back
#define pf                      push_front
#define F                       first
#define S                       second
#define mp                      make_pair
#define ort1                    exit(0);
#define nl                      endl

#define rep(i, l, r)            for(int i = (l); i <= (r); ++i)
#define per(i, l, r)            for(int i = (l); i >= (r); --i)
#define TL                      clock() / (double)CLOCKS_PER_SEC
#define NFS                     ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const ll INF = 1e12 + 1;
const int N = 1e3 + 9;

int n, r, c, m, q;
int x, y;
int a[N][N];
bool used[N][N];
string s;

void p(int x, int y){
    rep(i, 0, m - 1){
        a[x][y] = 1;
        if(s[i] == 'N') x--;
        if(s[i] == 'E') y++;
        if(s[i] == 'W') y--;
        if(s[i] == 'S') x++;
    }
    a[x][y] = 1;
}

void init(int R, int C, int sr, int sc, int M, char *S) {
    rep(i, 0, M - 1){
        s.pb(S[i]);
    }
    m = M;
    p(sr, sc);
}

inline void dfs(int x, int y, int ar, int ac, int br, int bc){
    used[x][y] = 1;
    if(a[x + 1][y] == 0 && x + 1 <= br && used[x + 1][y] == 0) dfs(x + 1, y, ar, ac, br, bc);
    if(a[x - 1][y] == 0 && x - 1 >= ar && used[x - 1][y] == 0) dfs(x - 1, y, ar, ac, br, bc);
    if(a[x][y + 1] == 0 && y + 1 <= bc && used[x][y + 1] == 0) dfs(x, y + 1, ar, ac, br, bc);
    if(a[x][y - 1] == 0 && y - 1 >= ac && used[x][y - 1] == 0) dfs(x, y - 1, ar, ac, br, bc);
}

int colour(int ar, int ac, int br, int bc){
    int cnt = 0;
    memset(used, 0, sizeof(used));
    rep(i, ar, br){
        rep(j, ac, bc){
            if(used[i][j] == 0 && a[i][j] == 0){
                cnt++;
                dfs(i, j, ar, ac, br, bc);
            }
        }
    }
    return cnt;
    return 0;
}

namespace read{
    static int R, C, M, Q;
    static int sr, sc;
    static char S[100000 + 5];
    void input(){
        scanf("%d %d %d %d", &R, &C, &M, &Q);
        scanf("%d %d", &sr, &sc);
        if (M > 0) {
            scanf(" %s ", S);
        }

        init(R, C, sr, sc, M, S);

        int query;
        for (query = 0; query < Q; query++) {
            int ar, ac, br, bc;
            scanf("%d %d %d %d", &ar, &ac, &br, &bc);
            printf("%d\n", colour(ar, ac, br, bc));
        }
    }
}

#ifdef ioi
int main(){
    read :: input();
    ort1
}
#endif

Compilation message

rainbow.cpp: In function 'void read::input()':
rainbow.cpp:89:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d", &R, &C, &M, &Q);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rainbow.cpp:90:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &sr, &sc);
         ~~~~~^~~~~~~~~~~~~~~~~~~
rainbow.cpp:92:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %s ", S);
             ~~~~~^~~~~~~~~~~
rainbow.cpp:100:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d %d %d", &ar, &ac, &br, &bc);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 1408 KB Output is correct
2 Correct 62 ms 1612 KB Output is correct
3 Correct 76 ms 1920 KB Output is correct
4 Correct 68 ms 1912 KB Output is correct
5 Correct 59 ms 1724 KB Output is correct
6 Correct 4 ms 1280 KB Output is correct
7 Correct 4 ms 1280 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 63 ms 1792 KB Output is correct
12 Correct 66 ms 2016 KB Output is correct
13 Correct 61 ms 1664 KB Output is correct
14 Correct 53 ms 1536 KB Output is correct
15 Correct 3 ms 1408 KB Output is correct
16 Correct 3 ms 1380 KB Output is correct
17 Correct 3 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1380 KB Output is correct
2 Correct 3 ms 1408 KB Output is correct
3 Execution timed out 3021 ms 23560 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Runtime error 6 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 1408 KB Output is correct
2 Correct 62 ms 1612 KB Output is correct
3 Correct 76 ms 1920 KB Output is correct
4 Correct 68 ms 1912 KB Output is correct
5 Correct 59 ms 1724 KB Output is correct
6 Correct 4 ms 1280 KB Output is correct
7 Correct 4 ms 1280 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 63 ms 1792 KB Output is correct
12 Correct 66 ms 2016 KB Output is correct
13 Correct 61 ms 1664 KB Output is correct
14 Correct 53 ms 1536 KB Output is correct
15 Correct 3 ms 1408 KB Output is correct
16 Correct 3 ms 1380 KB Output is correct
17 Correct 3 ms 1408 KB Output is correct
18 Execution timed out 3017 ms 23064 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 1408 KB Output is correct
2 Correct 62 ms 1612 KB Output is correct
3 Correct 76 ms 1920 KB Output is correct
4 Correct 68 ms 1912 KB Output is correct
5 Correct 59 ms 1724 KB Output is correct
6 Correct 4 ms 1280 KB Output is correct
7 Correct 4 ms 1280 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 3 ms 1408 KB Output is correct
11 Correct 63 ms 1792 KB Output is correct
12 Correct 66 ms 2016 KB Output is correct
13 Correct 61 ms 1664 KB Output is correct
14 Correct 53 ms 1536 KB Output is correct
15 Correct 3 ms 1408 KB Output is correct
16 Correct 3 ms 1380 KB Output is correct
17 Correct 3 ms 1408 KB Output is correct
18 Execution timed out 3017 ms 23064 KB Time limit exceeded
19 Halted 0 ms 0 KB -