QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#723845#5476. Remodeling the Dungeonemuach#Compile Error//C++232.4kb2024-11-08 01:24:162024-11-08 01:24:16

Judging History

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

  • [2024-11-08 01:24:16]
  • 评测
  • [2024-11-08 01:24:16]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops,inline")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
using namespace std;
const int maxN=1e3+5;
const int mod=998244353;
const int base=311;
int n,m,Time,d[maxN*maxN],num[maxN*maxN],out[maxN*maxN],up[maxN*maxN][18];
char a[maxN][maxN];
vector<int> adj[maxN*maxN];
void dfs(ll u,ll p){
    num[u]=++Time;
    up[u][0]=p;
    for(int i=1;i<18;i++)up[u][i]=up[up[u][i-1]][i-1];
    for(auto v:adj[u])if(v!=p)d[v]=d[u]+1,dfs(v,u);
    out[u]=Time;
}
bool is_ancestor(int u, int v){return num[u] <= num[v] && out[u] >= out[v];}
int lca(int u, int v){
    if (is_ancestor(u, v))return u;
    if (is_ancestor(v, u))return v;
    for (int i = 17; i >= 0; --i)
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    return up[u][0];
}
int dist(int u,int v){return d[u]+d[v]-2*d[lca(u,v)];}
void Enter(){
    cin>>n>>m;
    for(int i=1;i<=2*n+1;i++)cin>>a[i]+1;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
        if(a[2*i+1][2*j]=='.'){
            int u=(i-1)*m+j;
            int v=i*m+j;
            adj[u].pb(v);
            adj[v].pb(u);
        }
        if (a[2*i][2*j+1]=='.'){
            int u=(i-1)*m+j;
            int v=(i-1)*m+j+1;
            adj[u].pb(v);
            adj[v].pb(u);
        }
    }
    int last=n*m;
    dfs(last,last);
    int r=0;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
        if(a[2*i+1][2*j]!='.'&&i<n){
            int u=(i-1)*m+j;
            int v=i*m+j;
            int x=lca(1,u);
            if(x!=last&&!is_ancestor(x,v))r=max(r,d[v]+dist(1,u));
            x=lca(1,v);
            if(x!=last&&!is_ancestor(x,u))r=max(r,d[u]+dist(1,v));
        }
        if(a[2*i][2*j+1]!='.'&&j<m){
            int u=(i-1)*m+j;
            int v=(i-1)*m+j+1;
            int x=lca(1,u);
            if(x!=last&&!is_ancestor(x,v))r=max(r,d[v]+dist(1,u));
            x=lca(1,v);
            if(x!=last&&!is_ancestor(x,u))r=max(r,d[u]+dist(1,v));
        }
    }
    cout<<r+2;
}
//amogus
signed main(){
    //open("tbrackets");
    cin.tie(nullptr);ios_base::sync_with_stdio(NULL);
    //int t=1;cin>>t;while(t--)
    Enter();
}

Details

answer.code: In function ‘void Enter()’:
answer.code:36:33: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   36 |     for(int i=1;i<=2*n+1;i++)cin>>a[i]+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:2:
/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:36:39: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   36 |     for(int i=1;i<=2*n+1;i++)cin>>a[i]+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:36:39: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   36 |     for(int i=1;i<=2*n+1;i++)cin>>a[i]+1;
      |                                   ~~~~^~
      |                                       |
      |                                       char*
answer.code:36:39: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& a[i])) + 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:36:39: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   36 |     for(int i=1;i<=2*n+1;i++)cin>>a[i]+1;
      |                                   ~~~~^~
      |                                       |
      |                                       char*
answer.code:36:39: error: cannot bind rvalue ‘(long long int)(((char*)(& a[i])) + 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:36:39: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   36 |     for(int i=1;i<=2*n+1;i++)cin>>a[i]+1;
      |                                   ~~~~^~
      |                                       |
      |                                       char*
answer.code:36:39: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& a[i])) + 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:36:39: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   36 |     for(int i=1;i<=2*n+1;i++)cin>>a[i]+1;
      |                                   ~~~~^~
      |                                       |
      |                                       char*
answer.code:36:39: error: cannot bind rvalue ‘(long int)(((char*)(& a[i])) + 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>]’ ...