QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225394#5438. Half MixedLanceCompile Error//C++142.2kb2023-10-24 16:47:082023-10-24 16:47:09

Judging History

你现在查看的是最新测评结果

  • [2023-10-24 16:47:09]
  • 评测
  • [2023-10-24 16:47:08]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

void solve()
{
    LL n, m;
    cin >> n >> m;

    LL v1 = n * (n + 1) / 2, v2 = m * (m + 1) / 2;
    if (v1 % 2 == 1 && v2 % 2 == 1)
    {
        cout << "No\n";
        return;
    }

    vector ans(n, vector<int>(m));
    if (v1 % 2 == 0)
    {
        LL r1 = n * (n + 1) / 4, r2 = n;
        vector<int> len;
        while (true)
        {
            LL l = 1, r = r2;
            while (l < r)
            {
                LL mid = l + r + 1 >> 1;
                if (mid * (mid + 1) / 2 + r2 - mid <= r1) l = mid;
                else r = mid - 1;
            }

            r1 -= r * (r + 1) / 2, r2 -= r;
            len.push_back(r);
            if (r1 == 0) break;
        }

        int last = 0, v = 1;
        for (auto l : len)
        {
            for (int i = last; i < last + l; i ++ )
                ans[i][0] = v;
            last += l;
            v ^= 1;
        }

        for (int i = 0; i < n; i ++ )
            for (int j = 1; j < m; j ++ )
                ans[i][j] = ans[i][j - 1];
    }
    else
    {
        LL r1 = m * (m + 1) / 4, r2 = m;
        vector<int> len;
        while (true)
        {
            LL l = 1, r = r2;
            while (l < r)
            {
                LL mid = l + r + 1 >> 1;
                if (mid * (mid + 1) / 2 + r2 - mid <= r1) l = mid;
                else r = mid - 1;
            }

            r1 -= r * (r + 1) / 2, r2 -= r;
            len.push_back(r);
            if (r1 == 0) break;
        }

        int last = 0, v = 1;
        for (auto l : len)
        {
            for (int i = last; i < last + l; i ++ )
                ans[0][i] = v;
            last += l;
            v ^= 1;
        }

        for (int i = 1; i < n; i ++ )
            for (int j = 0; j < m; j ++ )
                ans[i][j] = ans[i - 1][j];
    }

    cout << "Yes\n";
    for (int i = 0; i < n; i ++ )
        for (int j = 0; j < m; j ++ )
            cout << ans[i][j] << " \n"[j == m - 1];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;

    while (T -- ) solve();

    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:19:12: error: missing template arguments before ‘ans’
   19 |     vector ans(n, vector<int>(m));
      |            ^~~
answer.code:43:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   43 |                 ans[i][0] = v;
      |                 ^~~
      |                 abs
answer.code:50:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   50 |                 ans[i][j] = ans[i][j - 1];
      |                 ^~~
      |                 abs
answer.code:75:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   75 |                 ans[0][i] = v;
      |                 ^~~
      |                 abs
answer.code:82:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   82 |                 ans[i][j] = ans[i - 1][j];
      |                 ^~~
      |                 abs
answer.code:88:21: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   88 |             cout << ans[i][j] << " \n"[j == m - 1];
      |                     ^~~
      |                     abs