제출 #580854

#제출 시각아이디문제언어결과실행 시간메모리
580854Metal_SonicBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
188 ms184304 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(x) (int)(x).size()
#define all(x) x.begin() , x.end()
void setIO(string name = "") {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
const int N = 3005;
ll I[N][N] , O[N][N];
vector<vector<ll>>J(N);
void run_test_case(){
    int n , m;cin>>n>>m;
    for(int i = 0; i < n; i++){
        string s;cin>>s;
        for(int j = 0; j < m; j++){
            if(s[j] == 'I')I[i][j]++;
            else if(s[j] == 'O')O[i][j]++;
            else J[i].push_back(j);
            if(j)O[i][j]+=O[i][j-1];
            if(i)I[i][j]+=I[i-1][j];
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(auto it : J[i]){
            ans+=(O[i][m-1]-O[i][it])*(I[n-1][it]-I[i][it]);
        }
    }
    cout<<ans;
}
int main() {
    setIO();
    int T = 1;
    while(T--){
        run_test_case();
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t1.cpp: In function 'void setIO(std::string)':
joi2019_ho_t1.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen((name+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen((name+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...