답안 #490706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490706 2021-11-28T20:16:31 Z Mr_Husanboy Red-blue table (IZhO19_stones) C++14
100 / 100
209 ms 3288 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;bool ok=1;
		if(n>m) swap(n,m),ok=0;
		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";if(ok){
		for(int i=0;i<n;i++) cout<<s[i]<<"\n";}else{
			for(int i=m-1;i>=0;i--){
				for(int j=0;j<n;j++){
					if(s[j][i]=='-') cout<<"+";else cout<<"-";
				}
				cout<<"\n";
			}
		}
		
		//cout<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 1320 KB Output is correct
2 Correct 209 ms 2020 KB Output is correct
3 Correct 169 ms 1936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 1316 KB Output is correct
2 Correct 132 ms 1828 KB Output is correct
3 Correct 139 ms 1652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 128 ms 1320 KB Output is correct
6 Correct 209 ms 2020 KB Output is correct
7 Correct 169 ms 1936 KB Output is correct
8 Correct 110 ms 1316 KB Output is correct
9 Correct 132 ms 1828 KB Output is correct
10 Correct 139 ms 1652 KB Output is correct
11 Correct 20 ms 440 KB Output is correct
12 Correct 159 ms 1644 KB Output is correct
13 Correct 134 ms 1756 KB Output is correct
14 Correct 95 ms 1192 KB Output is correct
15 Correct 176 ms 3288 KB Output is correct
16 Correct 166 ms 1872 KB Output is correct
17 Correct 65 ms 1220 KB Output is correct