| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 171909 | Swan | Marriage questions (IZhO14_marriage) | C++14 | 1579 ms | 2424 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define stop system("pause")
#define stop2 char o; cin >> o
#define INP freopen("pcb.in","r",stdin)
#define OUTP freopen ("pcb.out","w",stdout)
//#define int long long
using namespace std;
const int maxn = 100004;
vector<vector<int> > v;
main(){
    ios_base::sync_with_stdio(0);
    int n,m,k; cin >> n >> m >> k;
    v.resize(n+2);
    for(int i(0); i < k;i++){
        int a,b; cin >> a >> b;
        v[a].push_back(b);
    }
    int ans = 0;
    for(int l(1);l<=n;l++){
        set<int> s;
        int bad = 0;
        for(int r(l);r<=n;r++){
            for(int z(0); z < v[r].size();z++)s.insert(v[r][z]);
            if(!v[r].size())bad++;
            if(s.size()==m && s.size()<=(r-l+1)-bad){
                ans++;
                //cout << l << ' ' << r << ' ' << s.size() << endl;
            }
        }
    }
    cout << ans;
    return 0;
}
/*
10 4
1 5 5 5 10 4 4 2 3 1
*/
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
