Submission #480268

# Submission time Handle Problem Language Result Execution time Memory
480268 2021-10-15T12:26:46 Z luka1234 Red-blue table (IZhO19_stones) C++14
0 / 100
26 ms 1300 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		int mx=-1;
		int xans,yans,p;
		char a[n+1][m+1];
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				int p1=max(((m/2+1)-m+j),0);
				int p2=n-(n/2+1);
				if(i*p1<=j*p2){
					if((i+j)>mx){
						mx=i+j;
						xans=i;
						yans=j;
						p=p1;
					}
				}
			}
		}
		cout<<mx<<"\n";
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
			    a[i][j]='-';
		}
		for(int i=1;i<=xans;i++){
			for(int j=yans+1;j<=m;j++)
			    a[i][j]='+';
		}
		int pos=1;
		for(int i=1;i<=xans;i++){
			int v=min((pos+p-1),m);
			int v1=p-(v-pos+1);
			for(int j=pos;j<=v;j++)
			    a[i][j]='+';
			for(int j=1;j<=v1;j++)
			    a[i][j]='+';
			pos=v1+1;
			if(v1==0)
			   pos=v+1;			    
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
			    cout<<a[i][j];
			cout<<"\n";
		}
	}
    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:43:8: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |    int v1=p-(v-pos+1);
      |        ^~
stones.cpp:15:7: warning: 'xans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |   int xans,yans,p;
      |       ^~~~
stones.cpp:38:15: warning: 'yans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |        a[i][j]='+';
      |        ~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer in test 1 3: 2 < 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 7
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer in test 1 3: 2 < 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1300 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 972 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer in test 1 3: 2 < 3
2 Halted 0 ms 0 KB -