2 条题解

  • -1
    @ 2021-11-28 19:35:22
    #include<iostream>
    #include<stdio.h>
    using namespace std;
    int main(){
    	int n, a[105][105], b[105], c[105], sum = 0, ans = 0;
    	cin >> n; 
    	for(int i = 1; i <= n; i++){
    		for(int j = 1; j <= n; j++){
    			cin >> a[i][j];
    		}
    	}
    	int k = 0;
    	for(int i = 1; i <= n; i++){
    		for(int j = 1; j <= n; j++){
    			sum += a[i][j];
    		}
    		if(sum % 2 != 0){
    			b[k] = i;
    			k++;
    		}
    		sum = 0;
    	}
    	int l = 0;
    	for(int i = 1; i <= n; i++){
    		for(int j = 1; j <= n; j++){
    			ans += a[j][i];
    		}
    		if(ans % 2 != 0){
    			c[l] = i;
    			l++;
    		}
    		ans = 0;
    	}
    	if(l == 1 && k == 1){
    		cout << b[0] << " " << c[0];
    	}else if(l == 0 && k == 0){
    		cout << "OK";
    	}else{
    		cout << "Corrupt";
    	}
    	
    	return 0; 
    }
    • -3
      @ 2024-9-8 14:29:53
      #include<bits/stdc++.h>
      using  namespace std;
      int arr[105][105], h[105], l[105];
      int n;
      bool check(){
          for(int i = 1; i <= n; i++){
              if(h[i] % 2 != 0 || l[i] % 2 != 0){
                  return false;
              }
          }
          return true;
      }
      int main(){
          cin >> n;
          for(int i = 1; i <= n; i++){
              for(int j = 1; j <= n; j++){
                  cin >> arr[i][j];
                  if(arr[i][j] == 1) h[i]++, l[j]++;
              }
          }
          if(check() == true){
              cout << "OK";
              return 0;
          }
          int cnt = 0;
          int th, tl;
          for(int i = 1; i <= n; i++){
              for(int j = 1; j <= n; j++){
                  if(h[i] % 2 == 1 && l[j] % 2 == 1 && arr[i][j] == 1){
                      cnt++;
                      if(cnt == 1) th = i, tl = j;
                      h[i]--, l[j]--;
                  }
              }
          }
          if(cnt == 1) cout << th << " " << tl;
          else cout << "Corrupt";
          return 0;
      }
      
      • 1

      信息

      ID
      1040
      时间
      1000ms
      内存
      128MiB
      难度
      6
      标签
      递交数
      106
      已通过
      35
      上传者