QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#393250#8599. Кольорова таблицяNetwork_ErrorCompile Error//C++142.3kb2024-04-18 13:32:102024-04-18 13:32:11

Judging History

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

  • [2024-04-18 13:32:11]
  • 评测
  • [2024-04-18 13:32:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
//#define int long long
int n,m,c,L,a[110][110];
void out(int x){
	cout<<(x==0?'R':x==1?'G':'B');
}
void work(){
	cin>>n>>m>>c>>L;
	for(int i=1;i<=n;i++){
		char c;for(int j=1;j<=m;j++){
			cin>>c;a[i][j]=c=='R'?0:c=='G'?1:2; 
		}
	}
	if(c==2){
		int sum=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)sum+=a[i][j]!=(i+j)%2;
		if(sum<=L){
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++){
					out((i+j)&1);if(j==m)cout<<'\n';
				}
		}else{
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++){
					out((i+j+1)&1);if(j==m)cout<<'\n';
				}
		}
	}else{
		int c[3]={0,0,0};
		for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)++c[a[i][j]];
		int x=c[0]=min(c[0],c[1],c[2])?0:c[1]==min(c[0],c[1],c[2])?1:2;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				if(c[i][j]==x)c[i][j]=2;
				else if(c[i][j]==2)c[i][j]=x;
		
		int sum=0,cnt=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)if(a[i][j]!=2)cnt++,sum+=a[i][j]!=(i+j)%2;
		if(sum<=cnt/2){
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++){
					if(a[i][j]!=2)a[i][j]=(i+j)&1;
				}
			for(int i=1;i<=n;i++){
				for(int j=1;j<=m;j++){
					if((i+j+1)&1)continue;
					if(a[i][j]!=2||a[i-1][j]!=2&&a[i+1][j]!=2&&a[i][j-1]!=2&&a[i][j+1]!=2)continue;
					int x=0;
					if(i>1&&a[i-1][j]!=2)x=a[i-1][j]; 
					if(i<n&&a[i+1][j]!=2)x=a[i+1][j]; 
					if(j>1&&a[i][j-1]!=2)x=a[i][j-1]; 
					if(j<m&&a[i][j+1]!=2)x=a[i][j+1];a[i][j]=!x;
				}
			}
		}else{
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++){
					if(a[i][j]!=2)a[i][j]=(i+j+1)&1;
				}
			for(int i=1;i<=n;i++){
				for(int j=1;j<=m;j++){
					if((i+j)&1)continue;
					if(a[i][j]!=2||a[i-1][j]!=2&&a[i+1][j]!=2&&a[i][j-1]!=2&&a[i][j+1]!=2)continue;
					int x=0;
					if(i>1&&a[i-1][j]!=2)x=a[i-1][j]; 
					if(i<n&&a[i+1][j]!=2)x=a[i+1][j]; 
					if(j>1&&a[i][j-1]!=2)x=a[i][j-1]; 
					if(j<m&&a[i][j+1]!=2)x=a[i][j+1];a[i][j]=!x;
				}
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)out(a[i][j]);cout<<'\n';
		}
	}
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();return 0;
}


详细

answer.code: In function ‘void work()’:
answer.code:44:40: error: invalid types ‘int[int]’ for array subscript
   44 |                                 if(c[i][j]==x)c[i][j]=2;
      |                                        ^
answer.code:44:51: error: invalid types ‘int[int]’ for array subscript
   44 |                                 if(c[i][j]==x)c[i][j]=2;
      |                                                   ^
answer.code:45:45: error: invalid types ‘int[int]’ for array subscript
   45 |                                 else if(c[i][j]==2)c[i][j]=x;
      |                                             ^
answer.code:45:56: error: invalid types ‘int[int]’ for array subscript
   45 |                                 else if(c[i][j]==2)c[i][j]=x;
      |                                                        ^
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h: In instantiation of ‘constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]’:
answer.code:41:17:   required from here
/usr/include/c++/13/bits/stl_algobase.h:284:17: error: ‘__comp’ cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~