萌新第一天学c艹 , 36行性感小代码申请出战 , 10WA
查看原帖
萌新第一天学c艹 , 36行性感小代码申请出战 , 10WA
1122055
Gojo_Satoru2023楼主2024/7/24 15:42
#include <bits/stdc++.h>
using namespace std ;
#define int long long
const int N = 1005;
int m , n , k , l , d ;
int a[N] , b[N] ;
signed main(){
    cin >> m >> n >> k >> l >> d ;
    for(int i = 1 ; i <= d ; i ++){
        int x , y , p , q ;
        cin >> x >> y >> p >> q ;
        if(x == p){
            b[y] = 1 , b[q] = 1;
        }
        else{
            a[x] = 1 , a[p] = 1 ; 
        }
    }
    int cnt = 0 ;
    for(int i = 1 ; i <= n ; i ++){
        if(a[i] == 1 && a[i + 1] == 1){
            cout << i << " " ;
            cnt ++ ;
        }
        if(cnt == k) break ;
    }
    cnt = 0 ;
    cout << "\n" ;
    for(int i = 1 ; i <= m ; i ++){
        if(b[i] == 1 && b[i + 1] == 1){
            cout << i << " " ;
            cnt ++ ;
        }
        if(cnt == k) break ;
    }
}
2024/7/24 15:42
加载中...