제출 #1360858

#제출 시각아이디문제언어결과실행 시간메모리
1360858po_rag526Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
693 ms132940 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define int long long
using namespace std;
bool comprr(pair<int,int> a,pair<int,int> b){
    return a.second<b.second;
}
bool compll(pair<int,int> a,pair<int,int> b){
    return a.first<b.first;
}
signed main()
{
  int n,m;
  cin>>n>>m;
  char g[n][m];
  vector<pair<int,int>> fj;
  vector<int> iout[3001];
  vector<int> oin[3001];

  for(int i=0;i<n;i++){
      for(int t=0;t<m;t++){
          cin>>g[i][t];
          if(g[i][t]=='J'){
               fj.push_back({i,t});
          }
           if(g[i][t]=='I'){
             iout[t].push_back(i);
          } if(g[i][t]=='O'){
              oin[i].push_back(t);
          }
      }
  }
for(int i=1;i<=n;i++){
    sort(oin[i].begin(),oin[i].end());
}
for(int i=1;i<=m;i++){
    sort(iout[i].begin(),iout[i].end());
}
int say=0;
for(auto k : fj){
  int l=oin[k.first].end()-upper_bound(oin[k.first].begin(),oin[k.first].end(),k.second);
  int r=iout[k.second].end()-upper_bound(iout[k.second].begin(),iout[k.second].end(),k.first);
  say+=(l*r);
}
cout<<say;
}


//i j k l
//2 1 3 3
//i j    fj
//i l    fo
//k j    fi
//Condition: Bitaro has arranged a jewel on the square (i, j), an orb on the square (i, ?) and an ingot on
//the square (k, j).
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…