답안 #335709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335709 2020-12-13T18:26:06 Z shahriarkhan Bitaro the Brave (JOI19_ho_t1) C++14
50 / 100
1000 ms 81552 KB
#include<bits/stdc++.h>
using namespace std ;

//type 0 -> orb
//type 1 -> ingot

const int maxN = 3e3 + 5 ;

int SIZ[maxN][2] ;

vector<pair<int,int> > jewels ;

vector<int> mine[maxN][2] ;

long long bs(int low , int high , int type , int val , int par)
{
    if(high<low) return 0 ;
    int N = high + 1 ;
    while(low<high)
    {
        int mid = (low+high)/2 ;
        if(mine[par][type][mid]>val) high = mid ;
        else low = mid + 1 ;
    }
    if(mine[par][type][low]<=val) return 0 ;
    else return N - low ;
}

int main()
{
    long long ans = 0 ;
    string s[maxN] ;
    int H , W ;
    scanf("%d%d",&H,&W) ;
    for(int i = 0 ; i < H ; ++i)
    {
        cin>>s[i] ;
    }
    for(int i = 0 ; i < H ; ++i)
    {
        for(int j = 0 ; j < W ; ++j)
        {
            if(s[i][j]=='J') jewels.push_back({i,j}) ;
            else if(s[i][j]=='O') mine[i][0].push_back(j) ;
            else mine[j][1].push_back(i) ;
        }
    }
    for(int i = 0 ; i < maxN ; ++i)
    {
        if(!mine[i][0].empty())
        {
            sort(mine[i][0].begin(),mine[i][0].end()) ;
            SIZ[i][0] = mine[i][0].size() ;
        }
        if(!mine[i][1].empty())
        {
            sort(mine[i][1].begin(),mine[i][1].end()) ;
            SIZ[i][1] = mine[i][1].size() ;
        }
    }
    for(pair<int,int> p : jewels)
    {
        int i = p.first , j = p.second ;
        ans += (bs(0,SIZ[i][0]-1,0,j,i)*bs(0,SIZ[j][1]-1,1,i,j)) ;
    }
    printf("%lld\n",ans) ;
    return 0 ;
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     scanf("%d%d",&H,&W) ;
      |     ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 620 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 620 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 16 ms 2276 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 8 ms 1768 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 22 ms 3300 KB Output is correct
19 Correct 13 ms 2408 KB Output is correct
20 Correct 13 ms 2604 KB Output is correct
21 Correct 22 ms 3300 KB Output is correct
22 Correct 18 ms 2660 KB Output is correct
23 Correct 13 ms 2604 KB Output is correct
24 Correct 22 ms 2916 KB Output is correct
25 Correct 13 ms 2408 KB Output is correct
26 Correct 14 ms 2604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 620 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 16 ms 2276 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 8 ms 1768 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 22 ms 3300 KB Output is correct
19 Correct 13 ms 2408 KB Output is correct
20 Correct 13 ms 2604 KB Output is correct
21 Correct 22 ms 3300 KB Output is correct
22 Correct 18 ms 2660 KB Output is correct
23 Correct 13 ms 2604 KB Output is correct
24 Correct 22 ms 2916 KB Output is correct
25 Correct 13 ms 2408 KB Output is correct
26 Correct 14 ms 2604 KB Output is correct
27 Correct 907 ms 70744 KB Output is correct
28 Correct 2 ms 876 KB Output is correct
29 Correct 36 ms 6620 KB Output is correct
30 Correct 3 ms 876 KB Output is correct
31 Correct 630 ms 51764 KB Output is correct
32 Correct 515 ms 67428 KB Output is correct
33 Correct 575 ms 71312 KB Output is correct
34 Correct 738 ms 70068 KB Output is correct
35 Correct 679 ms 72756 KB Output is correct
36 Correct 578 ms 71320 KB Output is correct
37 Execution timed out 1016 ms 81552 KB Time limit exceeded
38 Halted 0 ms 0 KB -