# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341178 | juggernaut | Marriage questions (IZhO14_marriage) | C++14 | 1597 ms | 2284 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>
using namespace std;
vector<vector<int>>v;
int main(){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
v.resize(n+2);
while(k--){
int x,y;
scanf("%d%d",&x,&y);
v[x].push_back(y);
}
long long ans=0;
for(int l=1;l<=n;l++){
set<int>s;
int bad=0;
for(int r=l;r<=n;r++){
for(auto to:v[r])s.insert(to);
if(v[r].empty())bad++;
if(s.size()==m&&s.size()<=(r-l+1)-bad){
ans+=n-r+1;
break;
}
}
}
printf("%lld",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |