QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#521043#5416. Fabulous Fungus FrenzycqzhmCompile Error//C++202.1kb2024-08-15 20:24:262024-08-15 20:24:27

Judging History

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

  • [2024-08-15 20:24:27]
  • 评测
  • [2024-08-15 20:24:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN=505;
int n,m,k;
char s[MAXN];
int mp[MAXN][MAXN][MAXN],t[MAXN][MAXN];
int kn[MAXN],km[MAXN];
int cnt[MAXN<<2],vis[MAXN][MAXN];
struct node{
	int opt,x,y;
};
vector<node> ans;
inline int change(char x){
	if(x>='0' && x<='9') return x-'0'+1;
	if(x>='a' && x<='z') return x-'a'+1+11;
	if(x>='A' && x<='Z') return x-'A'+1+37;
}
inline int check(int d){
	memset(cnt,0,sizeof cnt);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cnt[t[i][j]]++;
	int sum=0;
	for(int i=1;i<=kn[d];i++) for(int j=1;j<=km[d];j++){
		if(cnt[mp[d][i][j]]) cnt[mp[d][i][j]]--,sum++;
		else if(cnt[0]) cnt[0]--;
		else return -1;
	}
	return sum;
}
inline void solve(int d){
	memset(vis,0,sizeof vis);
	for(int i=1;i<=kn[d];i++) for(int j=1;j<=km[d];j++){
		int x=0,y=0;
		for(int ii=1;!x && ii<=n;ii++) for(int jj=1;jj<=m;jj++) if(!vis[ii][jj] && mp[d][i][j]==t[ii][jj]) x=ii,y=jj;
		for(int ii=1;!x && ii<=n;ii++) for(int jj=1;jj<=m;jj++) if(!vis[ii][jj] && !t[ii][jj]) x=ii,y=jj;
		while(x<i) swap(t[x][y],t[x+1][y]),ans.push_back({-3,x++,y});
		while(y<j) swap(t[x][y],t[x][y+1]),ans.push_back({-1,x,y++});
		while(x>i) swap(t[x][y],t[x-1][y]),ans.push_back({-4,x--,y});
		while(y>j) swap(t[x][y],t[x][y-1]),ans.push_back({-2,x,y--});
		vis[i][j]=1;
	}
	for(int i=1;i<=kn[d];i++) for(int j=1;j<=km[d];j++) t[i][j]=0;
	if(d) ans.push_back({d,1,1});
}
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>k; kn[0]=n; km[0]=m;
	for(int i=1;i<=n;i++){
		cin>>s+1;
		for(int j=1;j<=m;j++) mp[0][i][j]=change(s[j]);
	}
	for(int i=1;i<=n;i++){
		cin>>s+1;
		for(int j=1;j<=m;j++) t[i][j]=change(s[j]);
	}
	for(int d=1;d<=k;d++){
		cin>>kn[d]>>km[d];
		for(int i=1;i<=kn[d];i++){
			cin>>s+1;
			for(int j=1;j<=km[d];j++)
				mp[d][i][j]=change(s[j]);
		}
	}
	while(1){
		if(check(0)>=0) break;
		bool flag=false;
		for(int i=1;i<=k;i++) if(check(i)>0) flag=true,solve(i);
		if(!flag) return cout<<-1<<'\n',0;
	}
	solve(0);
	reverse(ans.begin(),ans.end());
	cout<<ans.size()<<'\n';
	for(int i=0;i<ans.size();i++) cout<<ans[i].opt<<" "<<ans[i].x<<" "<<ans[i].y<<'\n';
	return 0;
}

Details

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