Submission #646437

#TimeUsernameProblemLanguageResultExecution timeMemory
646437murad_2005Red-blue table (IZhO19_stones)C++14
27 / 100
34 ms1304 KiB
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2") #pragma GCC optimize("unroll-loops") #define ll long long #define ld long double #define ull unsigned long long #define ui unsigned int #define eb emplace_back #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back #define pf push_front #define pii pair<int, int> #define pil pair<int, ll> #define plli pair<long long, int> #define pdi pair<double, int> #define pldldi pair<ld, pair<ld, int>> #define pdd pair<double, double> #define pid pair<int, double> #define piii pair<int, pair<int, int>> #define pllll pair<long long, long long> #define pllllll pair<ll, pllll> #define INF 2e9 + 5 #define size(v) v.size() #define f first #define s second #define Pi 3.14159265359 using namespace std; int Choice1(int n, int m){ int x = 0, best; while(x <= n){ if(n - x > x){ best = x; x++; }else{ break; } } return m + best; } int Choice2(int n, int m){ int x = 0, best; while(x <= m){ if(m - x > x){ best = x; x++; }else{ break; } } return n + best; } void solve(){ int n, m; cin >> n >> m; if(Choice1(n, m) > Choice2(n, m)){ // m > 2 * x cout << Choice1(n, m) << "\n"; int x = Choice1(n, m) - m; vector<vector<char>>grid(n + 1, vector<char>(m + 1, '-')); for(int i = 1; i <= x; i++){ for(int j = 1; j <= m; j++){ grid[i][j] = '+'; } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cout << grid[i][j]; } cout << "\n"; } }else{// n > 2 * x cout << Choice2(n, m) << "\n"; int x = Choice2(n, m) - n; vector<vector<char>>grid(n + 1, vector<char>(m + 1, '+')); for(int i = 1; i <= x; i++){ for(int j = 1; j <= n; j++){ grid[j][i] = '-'; } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cout << grid[i][j]; } cout << "\n"; } } } int main(){ int t; // t = 1; cin >> t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

stones.cpp: In function 'int Choice1(int, int)':
stones.cpp:42:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |     return m + best;
      |                ^~~~
stones.cpp: In function 'int Choice2(int, int)':
stones.cpp:55:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |     return n + best;
      |                ^~~~
stones.cpp: In function 'void solve()':
stones.cpp:55:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |     return n + best;
      |                ^~~~
stones.cpp:46:16: note: 'best' was declared here
   46 |     int x = 0, best;
      |                ^~~~
stones.cpp:81:26: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
   81 |         for(int i = 1; i <= x; i++){
      |                        ~~^~~~
stones.cpp:55:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |     return n + best;
      |                ^~~~
stones.cpp:46:16: note: 'best' was declared here
   46 |     int x = 0, best;
      |                ^~~~
#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...