Submission #203011

#TimeUsernameProblemLanguageResultExecution timeMemory
203011luciocfRed-blue table (IZhO19_stones)C++14
15 / 100
63 ms1912 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int maxn = 1e3+10; pii linha[maxn]; char tab[maxn][maxn]; int main(void) { int t; scanf("%d", &t); while (t--) { int n, m; scanf("%d %d", &n, &m); int mx = n, opt = 0; for (int B = 0; B <= m; B++) { int need = (m+2)/2 - (m-B); int qtd = B; if (need == 0) qtd += n; else { int x = (n - ((n+2)/2))*B; qtd += min(n, x/need); } if (qtd > mx) mx = qtd, opt = B; } for (int i = 1; i <= n; i++) linha[i] = {0, i}; printf("%d\n", mx); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) tab[i][j] = '-'; for (int i = 1; i <= n; i++) for (int j = 1; j <= m-opt; j++) tab[i][j] = '+'; for (int j = m-opt+1; j <= m; j++) { sort(linha+1, linha+n+1); for (int k = 1; k <= n - ((n+2)/2); k++) { tab[linha[k].second][j] = '+'; linha[k].first++; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) printf("%c", tab[i][j]); printf("\n"); } } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &t);
  ~~~~~^~~~~~~~~~
stones.cpp:21: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...