Submission #795823

#TimeUsernameProblemLanguageResultExecution timeMemory
795823Tien_NoobBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
214 ms53172 KiB
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
using namespace std;
const int N = 3001;
int a[N + 1][N + 1], n, m;
char s[N + 1][N + 1];
void read()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = 1; j <= m; ++ j)
        {
            cin >> s[i][j];
        }
    }
}
void solve()
{   
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = m; j >= 1; -- j)
        {
            a[i][j] = a[i][j + 1];
            if (s[i][j] == 'O')
            {
                ++a[i][j];
            }
        }
    }
    long long res = 0;
    for (int j = 1; j <= m; ++ j)
    {   
        int sum = 0;
        for (int i = 1; i <= n; ++ i)
        {
            if (s[i][j] == 'J')
            {
                sum += a[i][j];
            }
            if (s[i][j] == 'I')
            {
                res += sum;
            }
        }
    }
    cout << res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen(TASK".INP", "r"))
    {
        freopen(TASK".INP", "r", stdin);
        //freopen(TASK".OUT", "w", stdout);
    }
    int t = 1;
    bool typetest = false;
    if (typetest)
    {
        cin >> t;
    }
    for (int __ = 1; __ <= t; ++ __)
    {
        //cout << "Case " << __ << ": ";
        read();
        solve();
    }
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...