Submission #1166576

#TimeUsernameProblemLanguageResultExecution timeMemory
1166576dzhoz0Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
300 ms150636 KiB
/*
    ghmt the cutie :3
          UwU
*/

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

#define int long long
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>

const int MOD = 1'000'000'000 + 7;

void setIO(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    if (!name.empty())
    {
        freopen((name + ".INP").c_str(), "r", stdin);
        freopen((name + ".OUT").c_str(), "w", stdout);
    }
#endif
}
const int MAXN = 3000;
int n, m;
char a[MAXN + 5][MAXN + 5];
int co[MAXN + 5][MAXN + 5];
int ci[MAXN + 5][MAXN + 5];
void solve()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j= 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }    

    memset(co, 0, sizeof(co));
    for(int i = 1; i <= n; i++) {
        for(int j = m; j >= 1; j--) {
            co[i][j] = co[i][j + 1] + (a[i][j] == 'O');
        }
    }
    
    memset(ci, 0, sizeof(ci));
    for(int j = 1; j <= m; j++) {
        for(int i = n; i >= 1; i--) {
            ci[i][j] = ci[i + 1][j] + (a[i][j] == 'I');
        }
    }

    int res = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(a[i][j] == 'J') res += co[i][j] * ci[i][j];
        }
    }
    
    cout << res << '\n';
   
}
signed main()
{
    setIO();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'void setIO(std::string)':
joi2019_ho_t1.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen((name + ".INP").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen((name + ".OUT").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...