Submission #463634

#TimeUsernameProblemLanguageResultExecution timeMemory
463634fcmalkcinRed-blue table (IZhO19_stones)C++17
38 / 100
38 ms3144 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops, no-stack-protector") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned ll #define pll pair<ll,ll> #define ff first #define ss second #define pb push_back #define endl "\n" const ll maxn=2e3+100; const ll mod =1e9+7; const ll base=3e18; /// you will be the best but now you just are trash /// goal 5/7 char ans[maxn][maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen("t.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll t; cin>> t; while (t--) { ll n, m; ll res=0; cin>> n>> m; if (n+(m-1)/2>res) { res=n+(m-1)/2; for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { if (j<=m-(m-1)/2) { ans[i][j]='+'; } else { ans[i][j]='-'; } } } } if (n>=(n%2?1:2)&&n-(n%2?1:2)+((m-1)/2)*2>res) { res=n-(n%2?1:2)+((m-1)/2)*2; ll len=(m-1)/2; ll len1=(n/2)+1; for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { if (i<=len1&&j<=len) { ans[i][j]='-'; } else if (i>=n-len1+1&&j>=len+1&&j<=2*len) { ans[i][j]='-'; } else { ans[i][j]='+'; } // cout <<ans[i][j]; } // cout <<endl; } } if ((n-1)/2+m>res) { res=(n-1)/2+m; for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { if (i<=n-(n-1)/2) { ans[i][j]='-'; } else { ans[i][j]='+'; } } } } if (m>=(m%2?1:2)&&m-(m%2?1:2)+((n-1)/2)*2>res) { res=m-(m%2?1:2)+((n-1)/2)*2; // cout <<res<<endl; ll len=(n-1)/2; ll len1=(m/2)+1; for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { if (j<=len1&&i<=len) { ans[i][j]='+'; } else if (j>=m-len1+1&&i>=len+1&&i<=2*len) { ans[i][j]='+'; } else { ans[i][j]='-'; } // cout <<ans[i][j]; } // cout <<endl; } } cout <<res<<endl; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) cout <<ans[i][j]; cout <<endl; } } }

Compilation message (stderr)

stones.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization("unroll-loops, no-stack-protector")
      | 
stones.cpp: In function 'int main()':
stones.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...