QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#829934#9926. Flipping PathsCQXYM#Compile Error//C++111.8kb2024-12-24 14:53:372024-12-24 14:53:40

Judging History

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

  • [2024-12-24 14:53:40]
  • 评测
  • [2024-12-24 14:53:37]
  • 提交

answer

#include<iostream>
#include<string>
#include<vector>
using namespace std;
char C[200][201];
void Flip(char&C){
	if(C=='B'){
		C='W';
	}else{
		C='B';
	}
}
bool Paint(const int n,const int m,const char c,auto&Op){
	vector<string>().swap(Op);
	static char B[200][200];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			B[i][j]=C[i][j];
		}
	}
	//cout<<c<<endl;
	for(int i=1-m;i<n-2;i++){
		//cerr<<"M"<<endl;
		vector<pair<int,int>>Pos;
		for(int j=0;j<n-1;j++){
			int k=j-i;
			if(k>0&&k<m&&B[j][k]!=c){
				Pos.push_back(make_pair(j,k));
			}
		}
		/*printf("I%d\n",i);
		for(auto T:Pos){
			printf("%d %d\n",T.first,T.second);
		}*/
		if(Pos.empty()==false){
			Flip(B[0][0]);
			string Cur;
			int x=0,y=0;
			for(auto P:Pos){
				while(x<P.first){
					x++;
					Cur+='D';
					Flip(B[x][y]);
				}
				while(y<P.second){
					y++;
					Cur+='R';
					Flip(B[x][y]);
				}
			}
			while(x<n-1){
				x++;
				Cur+='D';
				Flip(B[x][y]);
			}
			while(y<m-1){
				y++;
				Cur+='R';
				Flip(B[x][y]);
			}
			Op.push_back(Cur);
			/*for(int i=0;i<n;i++){
				puts(B[i]);
			}*/
		}
	}
	for(int i=1;i<n;i++){
		if(B[i][0]!=B[0][0]){
			return false;
		}
	}
	for(int i=1;i<m;i++){
		if(B[n-1][i]!=B[0][0]){
			return false;
		}
	}
	if(B[0][0]!=c){
		string A(n-1,'D');
		A+=string(m-1,'R');
		Op.push_back(A);
	}
	return true;
}
void Solve(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%s",C+i);
	}
	vector<string>Op;
	if(Paint(n,m,'W',Op)==false){
		if(Paint(n,m,'B',Op)==false){
			puts("NO");
			return;
		}
	}
	cout<<"YES\n"<<Op.size()<<'\n';
	for(auto S:Op){
		cout<<S<<'\n';
	}
}
int main(){
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		Solve();
	}
	return 0;
}

Details

answer.code:13:49: error: use of ‘auto’ in parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’
   13 | bool Paint(const int n,const int m,const char c,auto&Op){
      |                                                 ^~~~
answer.code: In function ‘bool Paint(int, int, char, int&)’:
answer.code:14:31: error: cannot convert ‘int’ to ‘std::vector<std::__cxx11::basic_string<char> >&’
   14 |         vector<string>().swap(Op);
      |                               ^~
      |                               |
      |                               int
In file included from /usr/include/c++/13/vector:66,
                 from answer.code:3:
/usr/include/c++/13/bits/stl_vector.h:1583:20: note:   initializing argument 1 of ‘void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]’
 1583 |       swap(vector& __x) _GLIBCXX_NOEXCEPT
      |            ~~~~~~~~^~~
answer.code:61:28: error: request for member ‘push_back’ in ‘Op’, which is of non-class type ‘int’
   61 |                         Op.push_back(Cur);
      |                            ^~~~~~~~~
answer.code:80:20: error: request for member ‘push_back’ in ‘Op’, which is of non-class type ‘int’
   80 |                 Op.push_back(A);
      |                    ^~~~~~~~~
answer.code: In function ‘void Solve()’:
answer.code:88:25: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[201]’ [-Wformat=]
   88 |                 scanf("%s",C+i);
      |                        ~^  ~~~
      |                         |   |
      |                         |   char (*)[201]
      |                         char*
answer.code:91:26: error: invalid initialization of reference of type ‘int&’ from expression of type ‘std::vector<std::__cxx11::basic_string<char> >’
   91 |         if(Paint(n,m,'W',Op)==false){
      |                          ^~
answer.code:13:54: note: in passing argument 4 of ‘bool Paint(int, int, char, int&)’
   13 | bool Paint(const int n,const int m,const char c,auto&Op){
      |                                                 ~~~~~^~
answer.code:92:34: error: invalid initialization of reference of type ‘int&’ from expression of type ‘std::vector<std::__cxx11::basic_string<char> >’
   92 |                 if(Paint(n,m,'B',Op)==false){
      |                                  ^~
answer.code:13:54: note: in passing argument 4 of ‘bool Paint(int, int, char, int&)’
   13 | bool Paint(const int n,const int m,const char c,auto&Op){
      |                                                 ~~~~~^~
answer.code:86:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   86 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
answer.code:88:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   88 |                 scanf("%s",C+i);
      |                 ~~~~~^~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:104:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  104 |         scanf("%d",&t);
      |         ~~~~~^~~~~~~~~