Submission #336335

# Submission time Handle Problem Language Result Execution time Memory
336335 2020-12-15T05:07:18 Z Kerim Red-blue table (IZhO19_stones) C++17
0 / 100
92 ms 1516 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=1e3+4;
char res[N][N];
int main(){
    //freopen("file.in", "r", stdin);
    //freopen("grid.in", "w", stdout);
    int t=1;
    scanf("%d",&t);
    while(t--){
    	int n,m;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				res[i][j]='-';
		int ans=m,x=(m-1)/2,y=n/2+1,a=0,b=m;
		for(int A=1;A<=n;A++){
			if(y-(n-A)>0){
				int B=min(m,(A*x)/(y-(n-A)));
				if(umax(ans,A+B))
					a=A,b=B;
			//	printf("%d %d\n",A,B);
			}
			else{
				ans=A+m;
				a=A;b=m;
			}	
		}
		printf("%d\n",ans);
		printf("%d %d\n",n,m);
		priority_queue<PII>q;
		for(int i=1;i<=b;i++)
			q.push(mp((n-1)/2,i));
		for(int i=b+1;i<=m;i++)
			q.push(mp(n,i));
		vector<PII>tmp;
		for(int i=1;i<=a;i++){
			tmp.clear();
			for(int j=0;j<=m/2;j++){
				assert(!q.empty());
				PII nd=q.top();q.pop();
				assert(nd.ff>0);
				res[i][nd.ss]='+';
				tmp.pb(mp(nd.ff-1,nd.ss));
			}
			tr(it,tmp)
				q.push(*it);
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
				printf("%c",res[i][j]);
			puts("");	
		}
    }
	return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
stones.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |   scanf("%d%d",&n,&m);
      |   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 1516 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 1516 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -