Submission #171909

#TimeUsernameProblemLanguageResultExecution timeMemory
171909SwanMarriage questions (IZhO14_marriage)C++14
64 / 100
1579 ms2424 KiB
#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)

marriage.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
marriage.cpp: In function 'int main()':
marriage.cpp:26:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int z(0); z < v[r].size();z++)s.insert(v[r][z]);
                           ~~^~~~~~~~~~~~~
marriage.cpp:28:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(s.size()==m && s.size()<=(r-l+1)-bad){
                ~~~~~~~~^~~
marriage.cpp:28:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(s.size()==m && s.size()<=(r-l+1)-bad){
                               ~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...