Created
November 16, 2019 06:48
-
-
Save hsuan1117/803d98137eb013a61d177a43b5aaa8e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#define REP(n) for(int i = 0; i < n; i++) | |
#define _REP(n) for(int j = 0; j < n; j++) | |
typedef unsigned long long ull; | |
using namespace std; | |
char OR(char a, char b) { | |
return (a==b=='0'?'0':'1'); | |
} | |
int main() { | |
//improve input | |
ios::sync_with_stdio(false); | |
cin.tie(0); | |
cout.tie(0); | |
int diamondN,diamondLength,changeN; | |
cin >> diamondN >> diamondLength >> changeN; | |
vector<string> data; | |
for(int i=0; i< diamondN; i++) { | |
string temp; | |
cin >> temp ; | |
data.push_back(temp); | |
} | |
for(int i = 0; i < diamondLength; i++) { | |
bool found[300]; | |
memset(found,0,sizeof(found)); | |
int res = 0; | |
for(int j = 0; j < diamondN; j++) { | |
if(data[j][i] == '0') { | |
for(int k = 0; k < diamondLength; k++) { | |
if(data[j][k] == '1' && found[k] != '1') { | |
res++; | |
found[k] = 1; | |
} | |
} | |
} | |
} | |
if(i==diamondLength-1) { | |
cout << res << endl; | |
} | |
} | |
for(int m=0; m<changeN; m++) { | |
int c,d; | |
cin >> c >> d; | |
data.at(c-1)[d-1] = (data.at(c-1)[d-1]== '0'?'1':'0'); | |
for(int i = 0; i < diamondLength; i++) { | |
int res2 = 0; | |
bool found[300]; | |
memset(found,0,sizeof(found)); | |
for(int j = 0; j < diamondN; j++) { | |
if(data[j][i] == '0') { | |
for(int k = 0; k < diamondLength; k++) { | |
if(data[j][k] == '1' && found[k] != '1') { | |
res2++; | |
found[k] = 1; | |
} | |
} | |
} | |
} | |
if(i==diamondLength-1) { | |
cout << res2 << endl; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment