Submission #238848

#TimeUsernameProblemLanguageResultExecution timeMemory
238848arnold518Red-blue table (IZhO19_stones)C++14
0 / 100
59 ms1528 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1000; int TC, N, M; char S[MAXN+10][MAXN+10]; int main() { int i, j, k; scanf("%d", &TC); while(TC--) { scanf("%d%d", &N, &M); int ans=0; pii t; for(i=0; i<=N; i++) { for(j=0; j<=M; j++) { int x=min((M-1)/2, j); int y=max(0, i-(N-1)/2); if(x*i>=y*j) { if(ans<=i+j) ans=i+j, t={i, j}; } } } for(i=0; i<N; i++) for(j=0; j<M; j++) S[i][j]='-'; int a=t.first, b=t.second; int x=min((M-1)/2, b); int y=max(0, a-(N-1)/2); for(j=0, i=0; j<b; j++) { for(k=0; k<y; k++, i=(i+1)%a) { S[i][j]='+'; } } printf("%d\n", ans); for(i=0; i<N; i++) { for(j=0; j<M; j++) printf("%c", S[i][j]); printf("\n"); } } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:36:7: warning: unused variable 'x' [-Wunused-variable]
   int x=min((M-1)/2, b);
       ^
stones.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &TC);
  ~~~~~^~~~~~~~~~~
stones.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &N, &M);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...