QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401938#5438. Half MixedasaltfishCompile Error//C++232.0kb2024-04-29 16:57:172024-04-29 16:57:17

Judging History

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

  • [2024-04-29 16:57:17]
  • 评测
  • [2024-04-29 16:57:17]
  • 提交

answer

#define rep(a,b,c) for(int a=b;a<=c;a++)
#define dec(a,b,c) for(int a=b;a>=c;a--)
const int N = 1e6 + 10;
int n, m;
int a[N], g[N];

void init() {
    rep(i, 1, N - 5)
        a[i] = i * (i + 1) / 2;
}

void solve() {
    cin >> n >> m;
    if ((n * (n + 1) / 2 * m * (m + 1) / 2) & 1 || ((n * (n + 1) / 2 & 1) && (m * (m + 1) / 2 & 1))) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
    if ((n * (n + 1) / 2) % 2 == 0) {
        int k = n * (n + 1) / 4 - n, sum = 0;

        vector<int> v;
        dec(i, n, 1) {
            if (k == 0)
                break;
            int num = k / a[i];
            rep(j, 1, num) {
                sum += i + 1;
                v.push_back(i + 1);
            }
            k %= a[i];
        }
        sum = n - sum;
        rep(i, 1, sum)
            v.push_back(1);
        int st = 0;
        int idx = 1;

        for (auto i : v) {
            rep(j, 0, i - 1) {
                rep(k, 1, m) {
                    g[(idx + j - 1) * m + k] = st;
                }
            }
            idx += i;
            st ^= 1;
        }
        rep(i, 1, n)
            rep(j, 1, m)
            cout << g[(i - 1) * m + j] << " \n"[j == m];
    }
    else {
        int k = m * (m + 1) / 4 - m, sum = 0;

        vector<int> v;
        dec(i, m, 1) {
            int num = k / a[i];
            rep(j, 1, num) {
                sum += i + 1;
                v.pb(i + 1);
            }
            k %= a[i];
            if (!k) break;
        }
        sum = m - sum;
        rep(i, 1, sum)
            v.pb(1);

        int idx = 1, st = 0;
        for (auto i : v) {
            rep(j, 0, i - 1) {
                rep(k, 1, n)
                    g[(k - 1) * m + idx + j] = st;
            }
            idx += i;
            st ^= 1;
        }
        rep(i, 1, n)
            rep(j, 1, m)
            cout << g[(i - 1) * m + j] << " \n"[j == m];
    }
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:13:5: error: ‘cin’ was not declared in this scope
   13 |     cin >> n >> m;
      |     ^~~
answer.code:15:9: error: ‘cout’ was not declared in this scope
   15 |         cout << "No" << endl;
      |         ^~~~
answer.code:15:25: error: ‘endl’ was not declared in this scope
   15 |         cout << "No" << endl;
      |                         ^~~~
answer.code:18:5: error: ‘cout’ was not declared in this scope
   18 |     cout << "Yes" << endl;
      |     ^~~~
answer.code:18:22: error: ‘endl’ was not declared in this scope
   18 |     cout << "Yes" << endl;
      |                      ^~~~
answer.code:22:9: error: ‘vector’ was not declared in this scope
   22 |         vector<int> v;
      |         ^~~~~~
answer.code:22:16: error: expected primary-expression before ‘int’
   22 |         vector<int> v;
      |                ^~~
answer.code:29:17: error: ‘v’ was not declared in this scope
   29 |                 v.push_back(i + 1);
      |                 ^
answer.code:35:13: error: ‘v’ was not declared in this scope
   35 |             v.push_back(1);
      |             ^
answer.code:39:23: error: ‘v’ was not declared in this scope
   39 |         for (auto i : v) {
      |                       ^
answer.code:55:9: error: ‘vector’ was not declared in this scope
   55 |         vector<int> v;
      |         ^~~~~~
answer.code:55:16: error: expected primary-expression before ‘int’
   55 |         vector<int> v;
      |                ^~~
answer.code:60:17: error: ‘v’ was not declared in this scope
   60 |                 v.pb(i + 1);
      |                 ^
answer.code:67:13: error: ‘v’ was not declared in this scope
   67 |             v.pb(1);
      |             ^
answer.code:70:23: error: ‘v’ was not declared in this scope
   70 |         for (auto i : v) {
      |                       ^