제출 #202988

#제출 시각아이디문제언어결과실행 시간메모리
202988luciocfRed-blue table (IZhO19_stones)C++14
15 / 100
80 ms1912 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3+10; struct S { int ind, qtd; } col[maxn]; char tab[maxn][maxn]; bool comp(S a, S b) {return a.qtd > b.qtd;} int main(void) { int t; scanf("%d", &t); while (t--) { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= m; i++) col[i] = {i, n}; int mx = m, opt = 0; int tot = m; for (int A = 1; A <= n; A++) { sort(col+1, col+m+1, comp); for (int i = 1, cnt = 0; i <= m && cnt < (m+2)/2; i++) { cnt++; col[i].qtd--; if (col[i].qtd+1 >= (n+2)/2 && col[i].qtd < (n+2)/2) tot--; } if (A+tot > mx) { mx = A+tot; opt = A; } } for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) tab[i][j] = '-'; for (int i = 1; i <= m; i++) col[i] = {i, n}; for (int A = 1; A <= opt; A++) { sort(col+1, col+m+1, comp); for (int i = 1, cnt = 0; i <= m && cnt < (m+2)/2; i++) { cnt++; col[i].qtd--; tab[A][col[i].ind] = '+'; } } printf("%d\n", mx); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) printf("%c", tab[i][j]); printf("\n"); } } }

컴파일 시 표준 에러 (stderr) 메시지

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