답안 #880552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880552 2023-11-29T16:09:28 Z Mr_Husanboy Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
54 ms 14748 KB
#include <bits/stdc++.h>
using namespace std;



#ifdef LOCAL
#include "debugger.cpp"
#else
#define debug(...)
#endif
template<class T>
int len(T &a){
    return a.size();
}

using ll = long long;
using pii = pair<int,int>;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
string fileio = "";


mt19937 mt(time(nullptr));
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll infl = 1e18;
const int maxn = 1e5 + 1;





void solve(){
    int n, m; cin >> n >> m;
    vector<string> s(n);
    for(auto &u : s){
        cin >> u;
    }


    ll ans = 0;
    vector<ll> cnt(m);
    for(int i = n - 1; i >= 0; i --){
        ll cur = 0;
        for(int j = m - 1; j >= 0; j --){
            cur += (s[i][j] == 'O');
            cnt[j] += (s[i][j] == 'I');
            if(s[i][j] == 'J') ans += cur * cnt[j];
        }
    }
    debug(cnt);
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    auto start = chrono::high_resolution_clock::now();
    #ifndef LOCAL
    if(fileio.size()){
        freopen((fileio + ".in").c_str(), "r", stdin);
        freopen((fileio + ".out").c_str(), "w", stdout);
    }
    #endif
    int testcases = 1;
    #ifdef Tests
    cin >> testcases;
    #endif
    while(testcases --){
        solve();
        cout << '\n';
        #ifdef LOCAL
        cout << "_________________________" << endl;
        #endif
    }
    #ifdef LOCAL
    auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start);
    
    cout << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl;
    #endif
    return 0;
}           

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:58:10: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   58 |     auto start = chrono::high_resolution_clock::now();
      |          ^~~~~
joi2019_ho_t1.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen((fileio + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen((fileio + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 1 ms 856 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 2 ms 860 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 0 ms 464 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 1 ms 856 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 2 ms 860 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 46 ms 13976 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 2 ms 1468 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 36 ms 10324 KB Output is correct
32 Correct 25 ms 14748 KB Output is correct
33 Correct 24 ms 14672 KB Output is correct
34 Correct 38 ms 11856 KB Output is correct
35 Correct 25 ms 14580 KB Output is correct
36 Correct 27 ms 14696 KB Output is correct
37 Correct 54 ms 14672 KB Output is correct
38 Correct 21 ms 10264 KB Output is correct
39 Correct 17 ms 10320 KB Output is correct