Submission #341178

#TimeUsernameProblemLanguageResultExecution timeMemory
341178juggernautMarriage questions (IZhO14_marriage)C++14
66 / 100
1597 ms2284 KiB
#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)

marriage.cpp: In function 'int main()':
marriage.cpp:20:24: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |             if(s.size()==m&&s.size()<=(r-l+1)-bad){
      |                ~~~~~~~~^~~
marriage.cpp:20:37: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |             if(s.size()==m&&s.size()<=(r-l+1)-bad){
      |                             ~~~~~~~~^~~~~~~~~~~~~
marriage.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
marriage.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...