답안 #382103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382103 2021-03-26T11:52:40 Z vanic Red-blue table (IZhO19_stones) C++14
15 / 100
84 ms 1900 KB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <set>

using namespace std;

const int maxn=1005;

char c[maxn][maxn];
set < pair < int, int > > s;

void solve(){
	int n, m;
	cin >> n >> m;
	int c1=(n+2)/2;
	int c2=(m+2)/2;
	int uk=n*m;
	int sol=0;
	int naja, najb;
	int a, b;
	for(int i=0; i<=m; i++){
		a=i;
		b=min(n, (uk-c1*a)/c2);
		if(a+b>=sol){
			sol=a+b;
			naja=a;
			najb=b;
		}
	}
	cout << sol << '\n';
//	cout << naja << ' ' << najb << endl;
	for(int i=0; i<m; i++){
		s.insert({0, i});
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			c[i][j]='+';
		}
	}
	int cor;
	for(int i=0; i<najb; i++){
		for(int j=0; j<(m-1)/2; j++){
			cor=s.begin()->second;
			s.insert({s.begin()->first+1, s.begin()->second});
			s.erase(s.begin());
			c[i][cor]='-';
		}
	}
	for(int i=0; i<najb; i++){
		for(int j=0; j<m; j++){
			cout << c[i][j];
		}
		cout << '\n';
	}
	for(int i=0; i<n-najb; i++){
		for(int j=0; j<m; j++){
			cout << '-';
		}
		cout << '\n';
	}
	s.clear();
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

Compilation message

stones.cpp: In function 'void solve()':
stones.cpp:21:6: warning: variable 'naja' set but not used [-Wunused-but-set-variable]
   21 |  int naja, najb;
      |      ^~~~
stones.cpp:21:12: warning: 'najb' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |  int naja, najb;
      |            ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 81 ms 1420 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 1664 KB Output is correct
2 Correct 71 ms 1900 KB Output is correct
3 Correct 67 ms 1772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB in the table A+B is not equal to 5