Submission #1232637

#TimeUsernameProblemLanguageResultExecution timeMemory
1232637Bui_Quoc_CuongBitaro the Brave (JOI19_ho_t1)C++20
50 / 100
371 ms318004 KiB
# include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for (int i = a; i >= (int)b; i--)
const int MAXN = 3005;
int n, m;
int a[MAXN][MAXN];
int cntRow[MAXN][MAXN][4], cntCol[MAXN][MAXN][4];
signed main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    #define taskname "kieuoanh"
    if(fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin); 
        freopen(taskname".out", "w", stdout);
    }
    cin >> n >> m;
    FOR(i, 1, n) FOR(j, 1, m){
    	char x; cin >> x;
    	if(x == 'J') a[i][j] = 1;
    	if(x == 'O') a[i][j] = 2;
    	if(x == 'I') a[i][j] = 3;
    }
    FOR(t, 1, 3){
    	FOR(i, 1, n){
    		FOR(j, 1, m){
    			cntRow[i][j][t] = cntRow[i][j - 1][t] + (a[i][j] == t);
    			cntCol[i][j][t] = cntCol[i - 1][j][t] + (a[i][j] == t);
    		}
    	}
    }	
    long long ans = 0;
    FOR(i, 1, n) FOR(j, 1, m){
    	if(a[i][j] == 1){
    		int cnt2 = cntRow[i][m][2] - cntRow[i][j - 1][2];
    		int cnt3 = cntCol[n][j][3] - cntCol[i - 1][j][3];
    		ans+= 1LL * cnt2 * cnt3;
    	}
    }
    cout << ans;
    return 0;
}

Compilation message (stderr)

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