QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106724#5438. Half Mixedycccc319WA 203ms11272kbC++175.0kb2023-05-18 21:50:162023-05-18 21:50:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-18 21:50:17]
  • 评测
  • 测评结果:WA
  • 用时:203ms
  • 内存:11272kb
  • [2023-05-18 21:50:16]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define int long long
using namespace std;

ll C(ll n) {
    if (n == 0) {
        return 0;
    }
    return n * (n + 1) / 2;
}

ll c[1000010];


bool checker(vector<vector<int>> M, int n, int m) {
    int pure = 0, dirty = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int a = i; a < n; a++) {
                for (int b = j; b < m; b++) {
                    int zero = 0, one = 0;
                    for (int q = i; q <= a; q++) {
                        for (int w = j; w <= b; w++) {
                            if (M[q][w] == 0)zero++;
                            else one++;
                        }
                    }
                    if (zero == 0 || one == 0)pure++;
                    else dirty++;
                }
            }
        }
    }
    return pure == dirty;
}

void maker(int n, int m) {
    for (int t = 0; t < pow(2, n * m); t++) {
        vector<vector<int>> tmp;
        for (int i = 0; i < n; i++) {
            vector<int> temp;
            for (int j = 0; j < m; j++) {
                temp.push_back((t >> (i * m + j)) & 1);
            }
            tmp.push_back(temp);
            if (checker(tmp, n, m)) {
                for (auto to: tmp) {
                    for (auto tu: to) {
                        cout << tu << " ";
                    }
                    cout << endl;
                }
                cout << endl;
            }
        }
    }

}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(nullptr);
//    for(int i=1;i<=1000;i++)
//    {
//        cout<<i<<" "<<C(i+1)-C(i)<<endl;
//    }
    for (int i = 0; i <= 1000000; i++) {
        c[i] = C(i);
    }
//    cout << c[6 + 1] + c[3 + 1] + 1 * c[1] << endl;
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        swap(n, m);
        if (((n) * (n + 1) * (m) * (m + 1) / 4) & 1) {
            cout << "No\n";
            continue;
        }
        bool ok = 0;
//        int x=n,y=m;
        vector<int> tmp;
        int cn = (n) * (n + 1) / 4 - n;
        if (cn >= 0) {
            //        cout << cn + n << endl;
            while (cn > 0) {
                int wz = upper_bound(c, c + 1000000, cn) - c;
                wz--;
                tmp.push_back(wz + 1);
                cn -= c[wz];
            }
            int sum = 0;
            for (auto to: tmp) {
                sum += to;
//            cout << to << " ";
            }
            if (sum <= n) {
                ok = 1;
                cout << "Yes\n";
                bool now = 0;
                vector<bool> v;
                for (auto to: tmp) {
                    for (int i = 1; i <= to; i++) {
                        v.push_back(now);
                    }
                    now = !now;
                }
                for (int i = n - sum; i > 0; i--) {
                    v.push_back(now);
                    now = !now;
                }
                for (int i = 1; i <= m; i++) {
                    for (auto to: v) {
                        cout << to << " ";
                    }
                    cout << "\n";
                }
            }
        }

        if (ok)continue;
        tmp.clear();
        int cm = (m) * (m + 1) / 4 - m;
        if (cm >= 0) {
            //        cout << cn + n << endl;
            while (cm > 0) {
                int wz = upper_bound(c, c + 1000000, cm) - c;
                wz--;
                tmp.push_back(wz + 1);
                cm -= c[wz];
            }

            int sum = 0;
            for (auto to: tmp) {
                sum += to;
//            cout << to << " ";
            }
            if (sum <= m) {
                ok = 1;
                cout << "Yes\n";
                bool now = 0;
                vector<bool> v;
                for (auto to: tmp) {
//                cout << to << endl;
                    for (int i = 1; i <= to; i++) {
                        v.push_back(now);
                    }
                    now = !now;
                }
                for (int i = m - sum; i > 0; i--) {
                    v.push_back(now);
                    now = !now;
                }
                for (auto to: v) {
                    for (int i = 1; i <= n; i++) { cout << to << " "; }
                    cout << "\n";
                }
            }
        }
        if (!ok)cout << "No\n";
    }
//    ll n, m;
//    for (int n = 1; n <= 1000000; n++) {
////        cin>>n>>m;
//        ll ans = n * (n + 1) / 2;
////        ll x1,x2,y1,y2;
//        if (n % 4 != 0) {
//            continue;
//        }
//        bool ok = 0;
//        for (int i = 1; i <= n; i++) {
//            ll as = C(i) + n - i;
//            if (as == ans / 2) {
//                ok = 1;
//            }
//        }
//        if (ok == 0) {
//            cout << n << " ";
//        }
//    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 11256kb

input:

2
2 3
1 1

output:

Yes
0 1 0 
0 1 0 
No

result:

ok OK, Accepted. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 203ms
memory: 11272kb

input:

5382
1 1
1 2
2 1
1 3
2 2
3 1
1 4
2 3
3 2
4 1
1 5
2 4
3 3
4 2
5 1
1 6
2 5
3 4
4 3
5 2
6 1
1 7
2 6
3 5
4 4
5 3
6 2
7 1
1 8
2 7
3 6
4 5
5 4
6 3
7 2
8 1
1 9
2 8
3 7
4 6
5 5
6 4
7 3
8 2
9 1
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2
10 1
1 11
2 10
3 9
4 8
5 7
6 6
7 5
8 4
9 3
10 2
11 1
1 12
2 11
3 10
4 9
5 8
6 ...

output:

No
No
No
Yes
0 1 0 
No
Yes
0 
1 
0 
Yes
0 0 1 0 
Yes
0 1 0 
0 1 0 
Yes
0 0 
1 1 
0 0 
Yes
0 
0 
1 
0 
No
Yes
0 0 1 0 
0 0 1 0 
Yes
0 1 0 
0 1 0 
0 1 0 
Yes
0 0 
0 0 
1 1 
0 0 
No
No
No
Yes
0 0 1 0 
0 0 1 0 
0 0 1 0 
Yes
0 1 0 
0 1 0 
0 1 0 
0 1 0 
No
No
Yes
0 0 0 0 1 1 0 
No
Yes
0 0 1 1 0 
0 0 1 1 0...

result:

wrong answer 48 Mixed Submatrices Found, but 45 Expected (test case 24)