Submission #395791

#TimeUsernameProblemLanguageResultExecution timeMemory
395791CaroLindaRed-blue table (IZhO19_stones)C++14
100 / 100
69 ms2220 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb push_back #define sz(x) (int)(x.size()) using namespace std ; int T , N , M , K ; int teto(int num, int den) { return (num/den)+( num%den != 0 ) ; } void solve() { scanf("%d %d", &N, &M ) ; K = (N+2)>>1 ; vector<int> freq(N,M) ; vector< vector<char> > grid( N , vector<char>(M,'+') ) ; for(int ans = 1 ; ans <= N+M ; ans++ ) for(int linhas_zoadas = max(0, ans-M) ; linhas_zoadas <= min(N, ans) ; linhas_zoadas++ ) { int colunas_zoadas = ans-linhas_zoadas ; int k_azul = K-linhas_zoadas ; int k_verm = K-colunas_zoadas ; int worst_line = (N-linhas_zoadas) ? teto( k_azul*(M-colunas_zoadas) , N-linhas_zoadas ) : 0 ; if(worst_line*2 >= M) continue ; for(int a = 0 ; a < linhas_zoadas ; a++ ) for(int b = 0 ; b < M ; b++ ) grid[a][b] = '-' ; for(int a = colunas_zoadas , id = linhas_zoadas ; a < M ; a++ ) { int cnt = k_azul ; while(cnt--) { if(id == N) id = linhas_zoadas ; grid[id][a] = '-' ; id++ ; } } printf("%d\n", N+M-ans) ; for(int i = 0 ; i < N ; i++ , printf("\n")) for(int j = 0 ; j < M ; j++ ) printf("%c", grid[i][j] ) ; return ; } } int main() { scanf("%d", &T ) ; while(T--) solve() ; }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:29:8: warning: unused variable 'k_verm' [-Wunused-variable]
   29 |    int k_verm = K-colunas_zoadas ;
      |        ^~~~~~
stones.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d %d", &N, &M ) ;
      |  ~~~~~^~~~~~~~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   61 |  scanf("%d", &T ) ;
      |  ~~~~~^~~~~~~~~~~
#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...