답안 #1005644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005644 2024-06-22T17:10:43 Z MarwenElarbi Bitaro the Brave (JOI19_ho_t1) C++17
0 / 100
11 ms 344 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int nax=2e3+5;
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    optimise;   
    int n,m;
    cin>>n>>m;
    char grid[n][m];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin>>grid[i][j];
        }
    }
    long long ans=0;
    int xx[n][m];
    int yy[n][m];
    for (int i = 0; i < n; ++i)
    {
        int cur=0;
        for (int j = m-1; j >= 0; --j)
        {
            if(grid[i][j]=='O') cur++;
            xx[i][j]=cur;
        }
    }
    for (int j = 0; j < m; ++j)
    {
        int cur=0;
        for (int i = n-1; i >= 0; --i)
        {
            if(grid[i][j]=='I') cur++;
            yy[i][j]=cur;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if(grid[i][j]=='J'){
                ans+=yy[i][j]*xx[i][j];
            }
        }
    }
    cout <<ans<<endl;
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -