제출 #345491

#제출 시각아이디문제언어결과실행 시간메모리
345491georgerapeanuRed-blue table (IZhO19_stones)C++11
38 / 100
53 ms9840 KiB
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int t; int n,m; int main(){ scanf("%d",&t); while(t--){ scanf("%d %d",&n,&m); bool sw = (n > m); if(sw){ swap(n,m); } vector<vector<int> > ans(n + 1,vector<int>(m + 1)); int cnt_available = max(0,(n - 1) / 2) - 1; int lst = 1; int ans_sum = m; for(int i = 1;i <= n && cnt_available >= 0;i++){ bool success = true; for(int j = 0;j < m / 2 + 1;j++){ lst++; if(lst > m){ lst = 1; cnt_available--; if(cnt_available < 0){ success = false; break; } } ans[i][lst] = 1; } ans_sum += success; } if(sw){ swap(n,m); vector<vector<int> > tmp(n + 1,vector<int>(m + 1)); for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ tmp[i][j] = ans[j][i] ^ 1; } } ans = tmp; } printf("%d\n",ans_sum); for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ printf(ans[i][j] == 0 ? "-":"+"); } printf("\n"); } } return 0; }

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

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