답안 #233171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233171 2020-05-19T19:13:23 Z duality 치료 계획 (JOI20_treatment) C++11
0 / 100
3000 ms 760 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

char grid[500][500];
char ans[500][500];
int used[500][500];
int main() {
    int i,j;
    int R,C;
    scanf("%d %d",&R,&C);
    for (i = 0; i < R; i++) {
        for (j = 0; j < C; j++) scanf(" %c",&grid[i][j]),ans[i][j] = grid[i][j];
    }

    int t,c = 0;
    for (t = 0; t < 100*R*C; t++) {
        int x = 1+(rand() % (C-2)),y = 1+(rand() % (R-2));
        if ((grid[y][x] == 'W') && !used[y][x]) {
            if ((grid[y-1][x-1] == 'P') && (grid[y+1][x+1] == 'G') && !used[y-1][x-1] && !used[y+1][x+1]) {
                ans[y][x] = '\\',c++;
                used[y-1][x-1] = used[y][x] = used[y+1][x+1] = 1;
            }
            if ((grid[y-1][x-1] == 'G') && (grid[y+1][x+1] == 'P') && !used[y-1][x-1] && !used[y+1][x+1]) {
                ans[y][x] = '\\',c++;
                used[y-1][x-1] = used[y][x] = used[y+1][x+1] = 1;
            }
            if ((grid[y-1][x+1] == 'P') && (grid[y+1][x-1] == 'G') && !used[y-1][x+1] && !used[y+1][x-1]) {
                ans[y][x] = '/',c++;
                used[y-1][x+1] = used[y][x] = used[y+1][x-1] = 1;
            }
            if ((grid[y-1][x+1] == 'G') && (grid[y+1][x-1] == 'P') && !used[y-1][x+1] && !used[y+1][x-1]) {
                ans[y][x] = '/',c++;
                used[y-1][x+1] = used[y][x] = used[y+1][x-1] = 1;
            }
        }
        x = rand() % C;
        if ((grid[y][x] == 'W') && !used[y][x]) {
            if ((grid[y-1][x] == 'P') && (grid[y+1][x] == 'G') && !used[y-1][x] && !used[y+1][x]) {
                ans[y][x] = '|',c++;
                used[y-1][x] = used[y][x] = used[y+1][x] = 1;
            }
            if ((grid[y-1][x] == 'G') && (grid[y+1][x] == 'P') && !used[y-1][x] && !used[y+1][x]) {
                ans[y][x] = '|',c++;
                used[y-1][x] = used[y][x] = used[y+1][x] = 1;
            }
        }
        x = 1+(rand() % (C-1)),y = rand() % R;
        if ((grid[y][x] == 'W') && !used[y][x]) {
            if ((grid[y][x-1] == 'P') && (grid[y][x+1] == 'G') && !used[y][x-1] && !used[y][x+1]) {
                ans[y][x] = '-',c++;
                used[y][x-1] = used[y][x] = used[y][x+1] = 1;
            }
            if ((grid[y][x-1] == 'G') && (grid[y][x+1] == 'P') && !used[y][x-1] && !used[y][x+1]) {
                ans[y][x] = '-',c++;
                used[y][x-1] = used[y][x] = used[y][x+1] = 1;
            }
        }
    }
    cerr << c << endl;
    for (i = 0; i < R; i++) {
        for (j = 0; j < C; j++) printf("%c",ans[i][j]);
        printf("\n");
    }

    return 0;
}

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:64:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&R,&C);
     ~~~~~^~~~~~~~~~~~~~~
treatment.cpp:66:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for (j = 0; j < C; j++) scanf(" %c",&grid[i][j]),ans[i][j] = grid[i][j];
                                 ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3087 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3087 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -