QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401936#5438. Half MixedasaltfishCompile Error//C++202.0kb2024-04-29 16:56:542024-04-29 16:56:54

Judging History

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

  • [2024-04-29 16:56:54]
  • 评测
  • [2024-04-29 16:56:54]
  • 提交

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--)
#define pb push_back
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];
    }
}

Details

answer.code: In function ‘void solve()’:
answer.code:14:5: error: ‘cin’ was not declared in this scope
   14 |     cin >> n >> m;
      |     ^~~
answer.code:16:9: error: ‘cout’ was not declared in this scope
   16 |         cout << "No" << endl;
      |         ^~~~
answer.code:16:25: error: ‘endl’ was not declared in this scope
   16 |         cout << "No" << endl;
      |                         ^~~~
answer.code:19:5: error: ‘cout’ was not declared in this scope
   19 |     cout << "Yes" << endl;
      |     ^~~~
answer.code:19:22: error: ‘endl’ was not declared in this scope
   19 |     cout << "Yes" << endl;
      |                      ^~~~
answer.code:23:9: error: ‘vector’ was not declared in this scope
   23 |         vector<int> v;
      |         ^~~~~~
answer.code:23:16: error: expected primary-expression before ‘int’
   23 |         vector<int> v;
      |                ^~~
answer.code:30:17: error: ‘v’ was not declared in this scope
   30 |                 v.push_back(i + 1);
      |                 ^
answer.code:36:13: error: ‘v’ was not declared in this scope
   36 |             v.push_back(1);
      |             ^
answer.code:40:23: error: ‘v’ was not declared in this scope
   40 |         for (auto i : v) {
      |                       ^
answer.code:56:9: error: ‘vector’ was not declared in this scope
   56 |         vector<int> v;
      |         ^~~~~~
answer.code:56:16: error: expected primary-expression before ‘int’
   56 |         vector<int> v;
      |                ^~~
answer.code:61:17: error: ‘v’ was not declared in this scope
   61 |                 v.pb(i + 1);
      |                 ^
answer.code:68:13: error: ‘v’ was not declared in this scope
   68 |             v.pb(1);
      |             ^
answer.code:71:23: error: ‘v’ was not declared in this scope
   71 |         for (auto i : v) {
      |                       ^