QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#561719#5414. Stop, Yesterday Please No Morelouhao088#Compile Error//C++232.0kb2024-09-13 09:34:342024-09-13 09:34:39

Judging History

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

  • [2024-09-13 09:34:39]
  • 评测
  • [2024-09-13 09:34:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define fi first
#define se second
#define mp make_pair
const int maxn=1e6+5;
int T,n,m,k;
char a[maxn];
int ans;
pi st[maxn];
int s[1005][1005];
bool vis[1005][1005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>k;
        ans=0;
        int s1=0,s2=0,tot=0;
        int c1=0,c2=0,d1=0,d2=0;
        cin>>(a+1);
        ans=0;int len=strlen(a+1);
       // cout<<len<<endl;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)s[i][j]=vis[i][j]=0;
        for(int i=1;i<=len;i++){
            if(a[i]=='U')s1--;
            else if(a[i]=='D')s1++;
            if(a[i]=='L')s2--;
            else if(a[i]=='R')s2++;
            c1=max(c1,s1);c2=min(c2,s1);
            d1=max(d1,s2);d2=min(d2,s2);
            //cout<<s1<<" "<<s2<<endl;
        }
        //cout<<c1<<" "<<c2<<endl;
       // cout<<d1<<" "<<d2<<endl;
        c2=-c2+1;d2=-d2+1;
        c1=n-c1,d1=m-d1;
        swap(c1,c2),swap(d1,d2);
        //cout<<c1<<" "<<c2<<endl;
       // cout<<d1<<" "<<d2<<endl;

        int l=c2-c1,r=d2-d1;
        if(c1>c2||d1>d2){
            if(k==0){
                cout<<n*m<<endl;
            }
            else puts("0");
            continue;
        }
        st[++tot]=mp(c1,d1);vis[c1][d1]=1;
        for(int i=1;i<=len;i++){
            if(a[i]=='U')c1--;
            if(a[i]=='D')c1++;
            if(a[i]=='L')d1--;
            if(a[i]=='R')d1++;
            if(!vis[c1][d1])vis[c1][d1]=1,st[++tot]=mp(c1,d1);
        }
        
        for(int i=1;i<=tot;i++){
            int x=st[i].fi,y=st[i].se;
            s[x][y]++,s[x][y+r+1]--,s[x+l+1][y]--,s[x+l+1][y+r+1]++;
        }int u=(l+1)*(r+1);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
                if(u==s[i][j]+k)ans++;
            }
        cout<<ans<<endl;
    }
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:24:12: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   24 |         cin>>(a+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:24:16: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   24 |         cin>>(a+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:24:16: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   24 |         cin>>(a+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:24:16: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& a)) + 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:24:16: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   24 |         cin>>(a+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:24:16: error: cannot bind rvalue ‘(long long int)(((char*)(& a)) + 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:24:16: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   24 |         cin>>(a+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:24:16: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& a)) + 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:24:16: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   24 |         cin>>(a+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:24:16: error: cannot bind rvalue ‘(long int)(((char*)(& a)) + 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:24:16: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   24 |         cin>>(a+1);
      |              ~~^~~
      |                |
      |                char*
answer.code:24:16: error: cannot bind rvalue ‘(unsigned int)(((char*)(& a)) + 1)’ to ‘unsigned int&’
/usr/include/c++/13/istream:181:7: note: candidate: ‘std::b...