Submission #1273326

#TimeUsernameProblemLanguageResultExecution timeMemory
1273326nlhuyBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
134 ms79892 KiB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define Task "test"

typedef pair<int,int>ii;
typedef pair<ii,int>iii;

const int MOD = 1e9+7;
const int INF = 1e9+7;
const int Maxn = 1e5+7;
const int di[] = {0, 0, -1, 1};
const int dj[] = {-1, 1, 0, 0};

char a[3007][3007];
int f[3007][3007],g[3007][3007];

void run_case(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>a[i][j];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            f[i][j]=f[i][j-1]+(a[i][j]=='O');
            g[i][j]=g[i-1][j]+(a[i][j]=='I');
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if (a[i][j]=='J'){
                int x=g[n][j]-g[i][j];
                int y=f[i][m]-f[i][j];
                ans+=1LL*x*y;
            }
        }
    }
    cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    if (fopen(Task ".inp", "r"))
    {
        freopen(Task ".inp", "r", stdin);
        freopen(Task ".out", "w", stdout);
    }
    int t = 1;
    //cin >> t;
    while(t--){
        run_case();
    }
}

Compilation message (stderr)

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