QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574333#9132. Painting FencesIllusionaryDominanceCompile Error//C++201.8kb2024-09-18 21:36:162024-09-18 21:36:18

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 21:36:18]
  • 评测
  • [2024-09-18 21:36:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000000 + 5;

int N, M;
char str[MAX_N];
vector <int> sum[MAX_N];

inline int getSum(int xl, int yl, int xr, int yr) {
    return sum[xr][yr] - sum[xl - 1][yr] - sum[xr][yl - 1] + sum[xl - 1][yl - 1];
}

inline bool check(int xl, int yl, int xr, int yr) {
    return getSum(xl, yl, xr, yr) == (xr - xl + 1) * (yr - yl + 1);
}

inline int calc(int x, int p) {
    // p * (2^k - 1) >= x, minimize k
    // 2^k >= ceil(x / p) + 1
    // k >= ceil(log2(ceil(x / p) + 1))
    assert(p != 0);
    return ceil(log2((x - 1) / p + 2));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin >> N >> M;
    sum[0].resize(M + 1);
    for (int i = 0; i <= M; i ++) sum[0][i] = 0;
    for (int i = 1; i <= N; i ++) {
        cin >> (str + 1);
        sum[i].resize(M + 1);
        sum[i][0] = 0;
        for (int j = 1; j <= M; j ++) {
            sum[i][j] = (str[j] & 1) + sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
        }
    }
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= M; j ++) {
            int x = N - i, y = M - j;
            for (int k = 0; !k || (1 << k - 1) < x; k ++) {
                for (int l = 0; !l || (1 << l - 1) < y; l ++) {
                    int p = x / (1 << k) + 1, q = y / (1 << l) + 1;
                    if (check(i, j, i + p - 1, j + q - 1)) {
                        // fprintf(stderr, "i = %d, j = %d, k = %d, l = %d, p = %d, q = %d\n", i, j, k, l, p, q);
                        ans = min(ans, k + l + calc(i - 1, p) + calc(j - 1, q));
                    }
                }
            }
        }
    }
    cout << ans << '\n';
    
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:35:13: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   35 |         cin >> (str + 1);
      |         ~~~ ^~ ~~~~~~~~~
      |         |           |
      |         |           char*
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:35:21: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   35 |         cin >> (str + 1);
      |                ~~~~~^~~~
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:35:21: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   35 |         cin >> (str + 1);
      |                ~~~~~^~~~
      |                     |
      |                     char*
answer.code:35:21: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& str)) + 1)’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:35:21: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   35 |         cin >> (str + 1);
      |                ~~~~~^~~~
      |                     |
      |                     char*
answer.code:35:21: error: cannot bind rvalue ‘(long long int)(((char*)(& str)) + 1)’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:35:21: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   35 |         cin >> (str + 1);
      |                ~~~~~^~~~
      |                     |
      |                     char*
answer.code:35:21: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& str)) + 1)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:35:21: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   35 |         cin >> (str + 1);
      |                ~~~~~^~~~
      |                     |
      |                     char*
answer.code:35:21: error: cannot bind rvalue ‘(long int)(((char*)(& str)) + 1)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:184:7: note:   conversion of argument 1 would be ill-formed:
answer.code:35:21: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   35 |         cin >> (str + 1);
      |                ~~~~~^~~~
      |                     |
      |                     char*
answer.c...