Submission #809076

# Submission time Handle Problem Language Result Execution time Memory
809076 2023-08-05T15:40:49 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
20 / 100
131 ms 2272 KB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int h, w;
    cin >> h >> w;

    vector<vector<int>> J(h), O(h), I(w);

    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            if (s[j] == 'J')
            {
                J[i].push_back(j);
            }
            else if (s[j] == 'O')
            {
                O[i].push_back(j);
            }
            else
            {
                I[j].push_back(i);
            }
        }
    }

    for (int i = 0; i < w; i++)
    {
        sort(I[i].begin(), I[i].end());
    }

    int ans = 0;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < J[i].size(); j++)
        {
            for (int l = 0; l < O[i].size(); l++)
            {
                if (O[i][l] > J[i][j])
                {
                    int temp = I[J[i][j]].size();
                    int left = 0, right = I[J[i][j]].size() - 1;

                    while (left <= right)
                    {
                        int mid = left + (right - left) / 2;
                        if (I[J[i][j]][mid] > i)
                        {
                            temp = mid;
                            right = mid - 1;
                        }
                        else
                        {
                            left = mid + 1;
                        }
                    }

                    ans += I[J[i][j]].size() - temp;
                }
            }
        }
    }

    cout << ans;
    return 0;
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int j = 0; j < J[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~
joi2019_ho_t1.cpp:45:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for (int l = 0; l < O[i].size(); l++)
      |                             ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 43 ms 1724 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 10 ms 1172 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 64 ms 2272 KB Output is correct
19 Correct 15 ms 1876 KB Output is correct
20 Incorrect 131 ms 1608 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 43 ms 1724 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 10 ms 1172 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 64 ms 2272 KB Output is correct
19 Correct 15 ms 1876 KB Output is correct
20 Incorrect 131 ms 1608 KB Output isn't correct
21 Halted 0 ms 0 KB -