Submission #471016

# Submission time Handle Problem Language Result Execution time Memory
471016 2021-09-06T16:16:03 Z Killer2501 Red-blue table (IZhO19_stones) C++14
0 / 100
37 ms 4696 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "INTERNET"
#define pll pair<ll, ll>
#define pi pair<ll, pll>
#define fi first
#define se second

using namespace std;
const ll mod = 1e17;
const ll N = 3e3+5;
const int base = 350;
const int base2 = 311;
ll n, m, t, k, T, tong, a[N][N], b[N], c[N], d[N], ans, dp[N], lab[N], h[N], P[N][20];
vector<ll> adj[N], kq;
pll p[N];
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
string s;
bool cmp(pll x, pll y)
{
    return  (long double) 1.0 * x.se / x.fi > (long double) 1.0 * y.se / y.fi;
}
void sol()
{
    cin >> n >> m;
    bool ok = false;
    if(n < m)
    {
        swap(n, m);
        ok = true;
    }
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)a[i][j] = 1;
    }
    k = 0;
    for(int j = 1; j <= (m-1)/2; j ++)
    {
        for(int i = 1; i <= n; i ++)
        {
            ++k;
            a[i][tong+1] = 0;
            if(k == n/2+1)
            {
                k = 0;
                ++tong;
            }
        }
    }
    cout << n + tong << '\n';
    if(ok)swap(n, m);
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            if(ok)
            {
                if(a[j][i])cout << '-';
                else cout << '+';
            }
            else
            {
                if(a[i][j])cout << '+';
                else cout << '-';
            }
        }
        cout << '\n';
    }
}
int main()
{
    if(fopen(task".in", "r"))
    {
       freopen(task".in", "r", stdin);
       freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
5
100
12
8
2021
10000

*/

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:84:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:85:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB in the table A+B is not equal to 9
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 3720 KB in the table A+B is not equal to 97
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 4696 KB in the table A+B is not equal to 56
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB in the table A+B is not equal to 6