Submission #1151979

#TimeUsernameProblemLanguageResultExecution timeMemory
1151979AgentPenginBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
226 ms150412 KiB
/**
 *    author:  AgentPengin ( Độc cô cầu bại )
 *    created: 23.12.2022 10:08:02
 *    too lazy to update time
**/
#include<bits/stdc++.h>

#define EL '\n'
#define fi first
#define se second
#define NAME "TASK"
#define ll long long
#define lcm(a,b) (a/gcd(a,b))*b
#define db(val) "["#val" = " << (val) << "] "
#define bend(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
#define ex exit(0)
#define int ll

using namespace std;

const ll mod = 1e9 + 7;
const int inf = 0x1FFFFFFF;
const int MAXN = 1e5 + 5;

int n, m;
char c[3005][3005];

int p[3005][3005], u[3005][3005];

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    if (ifstream(NAME".inp")) {
        freopen(NAME".inp","r",stdin);
        freopen(NAME".out","w",stdout);
    }
    cin >> n >> m;
    for (int i = 1;i <= n;i++) {
    	for (int j = 1;j <= m;j++) {
    		cin >> c[i][j];
    	}
    }
    for (int i = 1;i <= n;i++) {
    	for (int j = m;j >= 1;j--) {
    		p[i][j] = p[i][j + 1] + (c[i][j] == 'O');
    	}
    }
    
    for (int j = 1;j <= m;j++) {
    	for (int i = n;i >= 1;i--) {
    		u[j][i] = u[j][i + 1] + (c[i][j] == 'I');
    	}
    }
    int ans = 0;
    for (int i = 1;i <= n;i++) {
    	for (int j = 1;j <= m;j++) {
    		ans += (c[i][j] == 'J') * p[i][j + 1] * u[j][i + 1];
    	}
    }
    cout << ans;
    
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
// agent pengin wants to take apio (with anya-san)

Compilation message (stderr)

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