QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#187334#3002. Busy BoardSolitaryDream#Compile Error//C++202.6kb2023-09-24 16:27:572023-09-24 16:27:57

Judging History

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

  • [2023-09-24 16:27:57]
  • 评测
  • [2023-09-24 16:27:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
#define DOR(i,s,t) for(int i=(s),_t=(t); i>=_t; --i)
typedef long long ll;
typedef double db;
const int N=1005;
char a[N][N];
char b[N][N];
vector<pair<int,int>> E[N][N];
int deg[N][N];
int mark[N][N];
int A[N],B[N];
int cnt1[N],cnt2[N];
queue<pair<int,int>> Q;
int n,m;
set<int> U[N][2],V[N][2];
void upd(int i,int j) {
    mark[i][j]=1;
    if(b[i][j]=='X') {
        --cnt1[i];
        U[i][1].erase(j);
        U[i][0].insert(j);
        if(cnt1[i]<=1) {
            for(auto p: U[i][cnt1[i]]) {
                if((--deg[i][p])==0) {
                    Q.push({i,p});
                }
            }
        }
        --cnt2[j];
        V[j][1].erase(i);
        V[j][0].insert(i);
        if(cnt2[j]<=1) {
            for(auto p: V[j][cnt2[j]]) {
                if((--deg[p][j])==0) {
                    Q.push({p,j});
                }
            }
        }
    } else {
        if((--deg[i][j])) {
            Q.push({i,j});
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(9);
    cin >> n >> m;
    FOR(i,1,n) cin >> a[i]+1;
    FOR(i,1,n) cin >> b[i]+1;
    int w=1;
    FOR(i,1,n) FOR(j,1,m) if(a[i][j]!=b[i][j]) {w=0;break;}
    if(w) {
        cout << "1\n";
        return 0;
    }
    FOR(i,1,n) FOR(j,1,m) {
        if(b[i][j]=='X') {
            cnt1[i]++,cnt2[j]++;
            U[i][1].insert(j);
            V[j][1].insert(i);
            deg[i][j]=2;
        } else {
            U[i][0].insert(j);
            V[j][0].insert(i);
            deg[i][j]=3;
        }
    }
    FOR(i,1,n) {
        if(cnt1[i]<=1) {
            for(auto p: U[i][cnt1[i]]) {
                if((--deg[i][p])==0) {
                    Q.push({i,p});
                }
            }
        }
    }
    FOR(j,1,m) {
        if(cnt2[j]<=1) {
            for(auto p: V[j][cnt2[j]]) {
                if((--deg[p][j])==0) {
                    Q.push({p,j});
                }
            }
        }
    }
    while(Q.size()) {
        auto [i,j]=Q.front();
        Q.pop();
        if(A[i]==0) {
            A[i]=1;
            FOR(k,1,m) if(!mark[i][k]) upd(i,k);
        }
        if(B[j]==0) {
            B[j]=1;
            FOR(k,1,n) if(!mark[k][j]) upd(k,j);
        }
    }
    int res=1;
    int c=0;
    FOR(i,1,n) FOR(j,1,m) {
        if(!A[i] && !B[j]) res&=(a[i][j]==b[i][j]);
        if(A[i] && B[j] && a[i][j]=='O') c=1;
    }
    res&=c;
    cout << res << '\n';
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:52:20: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   52 |     FOR(i,1,n) cin >> a[i]+1;
      |                ~~~ ^~ ~~~~~~
      |                |          |
      |                |          char*
      |                std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:27: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
   52 |     FOR(i,1,n) cin >> a[i]+1;
      |                       ~~~~^~
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:27: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
   52 |     FOR(i,1,n) cin >> a[i]+1;
      |                       ~~~~^~
      |                           |
      |                           char*
answer.code:52:27: error: cannot bind rvalue ‘(short int)(((char*)(& a[i])) + 1)’ to ‘short int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:27: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
   52 |     FOR(i,1,n) cin >> a[i]+1;
      |                       ~~~~^~
      |                           |
      |                           char*
answer.code:52:27: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& a[i])) + 1)’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:52:27: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
   52 |     FOR(i,1,n) cin >> a[i]+1;
      |                       ~~~~^~
      |                           |
      |                           char*
answer.code:52:27: error: cannot bind rvalue ‘(int)(((char*)(& a[i])) + 1)’ to ‘int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:182: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>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  182 |       operator>>(unsigned i...