QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#301308#6365. Cut the CakeSolitaryDream#WA 0ms3624kbC++171.3kb2024-01-09 17:38:442024-01-09 17:38:44

Judging History

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

  • [2024-01-09 17:38:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-01-09 17:38:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)

const int N=205;
int a[N][N],b[N],c[N],d[N][N];
int idx[N],idy[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,K;
    cin >> n >> m >> K;
    FOR(i,1,n) {
        string s;
        cin >> s;
        FOR(j,1,m) {
            a[i][j]=s[j-1]-'0';
            b[i]+=s[j-1]-'0';
            c[j]+=s[j-1]-'0';
        }
    }
    int s=0,k=1;
    vector<int> ans;
    FOR(i,1,n) {
        idx[i]=k;
        s+=b[i];
        if(s%K==0 && b[i] && i<n) {
            ++k;
            ans.push_back(i);
        }
    }
    s=0,k=1;
    FOR(i,1,m) {
        idy[i]=k;
        s+=c[i];
        if(s%K==0 && c[i] && i<m) {
            ++k;
            ans.push_back(i);
        }
    }
    if(ans.size()<K*2-2) {
        cout << "NO\n";
        return 0;
    }
    FOR(i,1,n) FOR(j,1,m) if(a[i][j]) {
        // cerr << j << ' ' << idy[j] << endl;
        d[idx[i]][idy[j]]++;
    }
    int res=1;
    FOR(i,1,K) FOR(j,1,K) if(!d[i][j]) {
        res=0;
    }
    if(!res) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    for(auto x: ans) {
        cout << x << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

4 4 2
1000
0001
0010
0001

output:

YES
2
3

result:

ok good plan

Test #2:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3 4 2
1110
0000
0100

output:

NO

result:

ok no solution

Test #3:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

10 10 2
0000000010
0000000000
0000000001
0000000000
0000000000
0000000000
0000100000
0000000000
0000001000
0000000000

output:

NO

result:

ok no solution

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3624kb

input:

10 10 2
0001000100
0000000000
0000100000
0000000000
0000000000
0000000000
0000000001
0000000000
0000000000
0000000000

output:

YES
1
7
5

result:

wrong output format Extra information in the output file