답안 #276969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276969 2020-08-20T22:01:42 Z Gilgamesh Bitaro the Brave (JOI19_ho_t1) C++17
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0}; 
const char dir[] = {'R', 'L', 'D', 'U'};
 
int add(int a, int b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}
 
int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}
 
int mult(int a, int b){
    return ((ll) a * b) % MOD;
}
 
void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line
 
int main(){
    setIO();
    int h, w; cin >> h >> w;
    int grid[h][w];
    for(int i = 0; i < h; ++i){
        string s; cin >> s;
        for(int j = 0; j < w; ++j){
            grid[i][j] = s[j] == 'J' ? 0 : s[j] == 'O' ? 1 : 2;
        }
    }
    int suffo[h][w], suffi[h][w];
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            suffo[i][j] = 0;
            suffi[i][j] = 0;
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = w - 1; j >= 0; --j){
            suffo[i][j] = grid[i][j] == 1 ? 1 : 0;
            if(j < w - 1) suffo[i][j] += suffo[i][j + 1];
        }
    }
    memset(suffi, 0, sizeof(suffi));
    for(int i = 0; i < w; ++i){
        for(int j = h - 1; j >= 0; --j){
            suffi[j][i] = grid[j][i] == 2 ? 1 : 0;
            if(j < h - 1) suffi[j][i] += suffi[j + 1][i];
        }
    }
    ll ans = 0;
    for(int i = 0; i < w; ++i){
        for(int j = 0; j < h; ++j){
            if(!grid[i][j]) {
                ans += (ll) suffo[i][j] * suffi[i][j];
            }
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -