UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197806#3433. CrisscrossZeardoe100108ms2268kbC++112.0kb2023-11-14 16:25:182023-11-14 17:29:24

answer

/*
[templates]: 
duipai
spjdp
compre
addhis
floor_sum
treedfs
matrix
network_flow
polynomial
lca
bitset
valuesgt
fenwick
erbitree
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//use ll instead of int.
#define f(i, a, b) for(int i = (a); i <= (b); i++)
#define cl(i, n) i.clear(),i.resize(n);
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 1e18;
//#define cerr if(false)cerr
//#define freopen if(false)freopen
mt19937 rng(time(0)); 
int rnd(int l, int r) {return rng() % (r-l+1) + l; }
#define watch(x) cerr  << (#x) << ' '<<'i'<<'s'<<' ' << x << endl
void pofe(int number, int bitnum) {
    string s; f(i, 0, bitnum) {s += char(number & 1) + '0'; number >>= 1; } 
    reverse(s.begin(), s.end()); cerr << s << endl; 
    return;
}
template <typename TYP> void cmax(TYP &x, TYP y) {if(x < y) x = y;}
template <typename TYP> void cmin(TYP &x, TYP y) {if(x > y) x = y;}
//调不出来给我对拍!
//use std::array.
const int N = 1000; 
char a[N + 10][N + 10]; 
int cntt[N + 10], cnttt[N + 10];
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen();
    //freopen();
    //time_t start = clock();
    //think twice,code once.
    //think once,debug forever.
    int n, m; cin >> n >> m; 
    f(i, 1, n) f(j, 1, m) cin >> a[i][j]; 
    int ans = 0; 
    f(i, 1, n) {
        int cnt = 0; f(j, 1, m) cnt += a[i][j] == '0';
        cntt[i] = cnt; 
    }
    f(i, 1, m) {
        int cnt = 0; f(j, 1, n) cnt += a[j][i] == '0';
        cnttt[i] = cnt; 
    }
    f(i, 1, n) ans += cntt[i] > 0;
    f(i, 1, m) ans += cnttt[i] > 0;
    f(i, 1, n) f(j, 1, m) ans -= cntt[i] == 1 && cnttt[j] == 1 && a[i][j] == '0'; 
    cout << (int)(ans + 1)  << endl; 
    //time_t finish = clock();
    //cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 1ms
memory: 1268kb

input:

4 4
1111
1011
1100
1100

output:

6

result:

ok 1 number(s): "6"

Test #2:

score: 10
Accepted
time: 0ms
memory: 1268kb

input:

1 1000
011001110110011101110110000011110011001001110111010001110001110100100010011010001001110111100...

output:

488

result:

ok 1 number(s): "488"

Test #3:

score: 10
Accepted
time: 0ms
memory: 1268kb

input:

1 1000
001110111101111001001110111111000101001110110110101100001111010001101111010100010010010001011...

output:

482

result:

ok 1 number(s): "482"

Test #4:

score: 10
Accepted
time: 19ms
memory: 2264kb

input:

1000 1000
010101000000101000010101111101010010100110110001100011110010100001010011001010110001001101...

output:

2001

result:

ok 1 number(s): "2001"

Test #5:

score: 10
Accepted
time: 19ms
memory: 2268kb

input:

1000 1000
000001101010101101101001010100001000011110100000011011010101000000000111001011010110011110...

output:

2001

result:

ok 1 number(s): "2001"

Test #6:

score: 10
Accepted
time: 23ms
memory: 2264kb

input:

1000 1000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

2001

result:

ok 1 number(s): "2001"

Test #7:

score: 10
Accepted
time: 13ms
memory: 2264kb

input:

1000 1000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

2001

result:

ok 1 number(s): "2001"

Test #8:

score: 10
Accepted
time: 12ms
memory: 2268kb

input:

1000 1000
100000010101010111000001011110000000001100000011110001110010101011110100000010011000011100...

output:

2001

result:

ok 1 number(s): "2001"

Test #9:

score: 10
Accepted
time: 9ms
memory: 2268kb

input:

1000 1000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

2001

result:

ok 1 number(s): "2001"

Test #10:

score: 10
Accepted
time: 12ms
memory: 2264kb

input:

1000 1000
110001000111111010010100001000100011010001001101000001001001010111010101010111111110100001...

output:

2001

result:

ok 1 number(s): "2001"

Extra Test:

score: 0
Extra Test Passed