Submission #1287845

#TimeUsernameProblemLanguageResultExecution timeMemory
1287845quan606303Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
230 ms71048 KiB
/*
 * @Author: RMQuan 
 * @Date: 2025-11-05 14:48:01 
 * @Last Modified by: RMQuan
 * @Last Modified time: 2025-11-05 14:59:13
 */
/*idea : 



*/
#include <bits/stdc++.h>
bool M1;
#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define TASK "TEST"
#define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
using namespace std;
const int MOD=1e9+7;
const int maxn=3005;
int a[maxn][maxn],n,m;
int cnt_O[maxn],cnt_I[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    file();
    cin>>n>>m;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            char x;
            cin>>x;
            if (x=='J')a[i][j]=1;
            else if (x=='O')a[i][j]=2;
            else if (x=='I')a[i][j]=3;
            if (a[i][j]==2)cnt_O[i]++;
            else if (a[i][j]==3)cnt_I[j]++;
        }
    }
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            if (a[i][j]==1)ans+=cnt_O[i]*cnt_I[j];
            if (a[i][j]==2)cnt_O[i]--;
            else if (a[i][j]==3)cnt_I[j]--;
        }
    }
    cout<<ans;
    return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:25:50: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 | #define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
      |                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:36:5: note: in expansion of macro 'file'
   36 |     file();
      |     ^~~~
joi2019_ho_t1.cpp:25:81: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 | #define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
      |                                                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:36:5: note: in expansion of macro 'file'
   36 |     file();
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...