제출 #1341896

#제출 시각아이디문제언어결과실행 시간메모리
1341896top1svtinBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
137 ms150412 KiB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline")

#include <bits/stdc++.h>

using namespace std;

#define kien long long
#define pb push_back
#define FOR(i, a, b) for (int i = a;i <= b; i++)
#define FORD(i, a, b) for (int i = a;i >= b; i--)
#define pii pair<int, int>
#define dembit(a) __builtin_popcountll(a)
#define task "a"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define debug(x) cout << x << " ";
#define down cout << "\n"
const kien MOD = 1e9 + 7;
const int NTEST = 100;
const int Million = 1e6 + 5;
const int MXN = 1e5 + 5;
mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count());
kien rand(kien l, kien r) {
  assert(l <= r);
  return uniform_int_distribution<kien>(l, r)(rd);
}

kien n, k, m, dem, f[MXN + 5], u, v, a[1000000];
kien maxx, minn, vtr, l, r, ans, row[3005][3005], col[3005][3005];
char c[3005][3005];

void solve() {
    cin >> n >> m; string s;
    FOR (i, 1, n) {
        cin >> s;
        FOR (j, 0, s.size() - 1) c[i][j + 1] = s[j];
    }

    FOR (i, 1, n) {
        FORD (j, m, 1) {
            row[i][j] = row[i][j + 1];
            if (c[i][j] == 'O') row[i][j] = row[i][j + 1] + 1;
        }
    }

    FORD (i, n, 1) {
        FOR (j, 1, m) {
            col[i][j] = col[i + 1][j];
            if (c[i][j] == 'I') col[i][j] = col[i + 1][j] + 1;
        }
    }

    FOR (i, 1, n) FOR (j, 1, m) {
        if (c[i][j] == 'J') ans += (row[i][j] * col[i][j]);
    }

    cout << ans;
}

main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  if (fopen(task".inp", "r")) {
      fin(task); fou(task);
  }
  int t = 1;  //cin >> t;
  while(t--) solve();

  cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "s ";
}

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t1.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:16:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:67:7: note: in expansion of macro 'fin'
   67 |       fin(task); fou(task);
      |       ^~~
joi2019_ho_t1.cpp:17:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:67:18: note: in expansion of macro 'fou'
   67 |       fin(task); fou(task);
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...