# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336236 | 2020-12-15T03:18:46 Z | Kerim | Red-blue table (IZhO19_stones) | C++17 | 80 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); int t; 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=(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); priority_queue<PII>q; for(int i=1;i<=m;i++) q.push(mp(0,i)); for(int i=1;i<=a;i++) for(int j=0;j<=m/2;j++){ PII nd=q.top();q.pop(); res[i][nd.ss]='+'; q.push(mp(nd.ff-1,nd.ss)); } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) printf("%c",res[i][j]); puts(""); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 364 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 76 ms | 1516 KB | in the table A+B is not equal to 539 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 80 ms | 1516 KB | in the table A+B is not equal to 144 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 |