Submission #634862

#TimeUsernameProblemLanguageResultExecution timeMemory
634862ghostwriterBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
177 ms53280 KiB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Cay ngay cay dem nhung deo duoc cong nhan
*/
const int N = 3002;
int h, w, d[N][N];
char a[N][N];
ll rs = 0;
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
    cin >> h >> w;
    FOR(i, 1, h)
    FOR(j, 1, w)
    	cin >> a[i][j];
    FOS(i, h, 1)
    FOR(j, 1, w)
    	if (a[i][j] == 'I') d[i][j] = d[i + 1][j] + 1;
    	else d[i][j] = d[i + 1][j];
    FOR(i, 1, h) {
    	int cnt = 0;
    	FOS(j, w, 1) {
    		if (a[i][j] == 'O') ++cnt;
    		if (a[i][j] != 'J') continue;
    		rs += 1LL * cnt * d[i][j];
    	}
    }
    cout << rs;
    return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t1.cpp:45:5: note: in expansion of macro 'FOR'
   45 |     FOR(i, 1, h)
      |     ^~~
joi2019_ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t1.cpp:46:5: note: in expansion of macro 'FOR'
   46 |     FOR(j, 1, w)
      |     ^~~
joi2019_ho_t1.cpp:25:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
joi2019_ho_t1.cpp:48:5: note: in expansion of macro 'FOS'
   48 |     FOS(i, h, 1)
      |     ^~~
joi2019_ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t1.cpp:49:5: note: in expansion of macro 'FOR'
   49 |     FOR(j, 1, w)
      |     ^~~
joi2019_ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
joi2019_ho_t1.cpp:52:5: note: in expansion of macro 'FOR'
   52 |     FOR(i, 1, h) {
      |     ^~~
joi2019_ho_t1.cpp:25:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
joi2019_ho_t1.cpp:54:6: note: in expansion of macro 'FOS'
   54 |      FOS(j, w, 1) {
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...