제출 #93411

#제출 시각아이디문제언어결과실행 시간메모리
93411inom결혼 문제 (IZhO14_marriage)C++14
32 / 100
1585 ms2808 KiB
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define int long long
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
 
using namespace std;

const int N = 30030;
 
int TN = 1;

int n, m, k;
int cnt, ans;
int us[N][55];
bool flag = false;
vector<int> verr[N];

void rec(int a, int b, int cnt, int pos) {
    if (a > b) {
        if (cnt >= m) {
            flag = true; return;
        } else {
            return;
        }
    }
    if (cnt >= m) {
        flag = true; return;
    }
    for (auto i: verr[a]) {
        if (!us[pos][i]) {
            us[pos][i] = 1;
            rec(a + 1, b, cnt + 1, pos);
            us[pos][i] = 0;
        }
    }
    rec(a + 1, b, cnt, pos);
}

void solve() {
    scanf("%lld %lld %lld", &n, &m, &k);
    for (int i = 1; i <= k; i++) {
        int x, y; 
        scanf("%lld %lld", &x, &y); verr[x].push_back(y);
    }
    for (int l = 1; l <= n; l++) {
        for (int r = l + m - 1; r <= n; r++) {
            flag = false; cnt = 0;
            rec(l, r, cnt, ans + 1); ans += flag;
        }
    }
    printf("%lld\n", ans);
    return;
}

signed main() {
    // in; out; // cin >> TN;
    while (TN--) { solve(); }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

marriage.cpp: In function 'void solve()':
marriage.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
marriage.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &x, &y); verr[x].push_back(y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...