Submission #1038631

#TimeUsernameProblemLanguageResultExecution timeMemory
1038631khanhtbBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
230 ms159240 KiB
// #pragma GCC optimize("O3,unroll-loops") // #pragma GCC targt("avx2,bmi,bmi2,popcnt,lzcnt") #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll, ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 998244353; const ll inf = 1e18; const ll blocksz = 320; const ll N = 3e3+8; int n,m; char a[N][N]; ll pre[N][N],suf[N][N]; void solve(){ 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 = m; j >= 1; j--){ if(a[i][j] == 'O') pre[i][j]++; pre[i][j] += pre[i][j+1]; } } for(int j = 1; j <= m; j++){ for(int i = n; i >= 1; i--){ if(a[i][j] == 'I') suf[i][j]++; suf[i][j] += suf[i+1][j]; } } ll ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(a[i][j] == 'J'){ ans += pre[i][j]*suf[i][j]; } } } cout << ans; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if (fopen("test.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll T = 1; // cin >> T; for (ll i = 1; i <= T; i++){ solve(); cout << '\n'; } }

Compilation message (stderr)

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