Submission #490702

# Submission time Handle Problem Language Result Execution time Memory
490702 2021-11-28T19:57:31 Z Mr_Husanboy Red-blue table (IZhO19_stones) C++14
15 / 100
130 ms 1832 KB
// Muallif: Mansuraliyev Husanboy Murotali o'g'li  >> NamPS

#include<bits/stdc++.h>

using namespace std;
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const double PI=3.1415926535897932384626433832795;
// 0-9 >> 48-57;    A-Z>>65-90   and   a-z>>97-122 respectively;



int main()
{
	ios;int t; cin>>t;while(t--){
		map<int,int>row,col;
		int n,m;
		cin>>n>>m;
		if(m==1){
		cout<<n<<"\n";for(int i=0;i<n;i++)cout<<"+\n";continue;} 
		int mr=m/2+1,mc=(n-1)/2;
		int mx=0;
		
		string s[n];
		for(int i=0;i<n;i++){
			int mxx=mx;
			for(int j=0;j<m;j++){
				
				if(col[j]<mc){
					if(row[i]<mr){
						if(col[j]<mxx||mr-row[i]>=m-j){
							s[i]+="+";col[j]++;row[i]++;
						}else s[i]+="-";
					}else{
						s[i]+="-";
					}
				}else{
					s[i]+="-";
				}
				mx=max(mx,col[j]);
			}
		}
		int ans=0;
		for(int i=0;i<n;i++){
			if(row[i]>=mr) ans++;
		}
		for(int j=0;j<m;j++) if(col[j]<=mc) ans++;
		cout<<ans<<"\n";
		for(int i=0;i<n;i++) cout<<s[i]<<"\n";//cout<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Wrong answer in test 20 2: 11 < 20
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 1284 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 123 ms 1348 KB Output is correct
2 Correct 119 ms 1832 KB Output is correct
3 Correct 130 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Wrong answer in test 4 3: 4 < 5