답안 #341178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341178 2020-12-29T05:10:37 Z juggernaut 결혼 문제 (IZhO14_marriage) C++14
66 / 100
1500 ms 2284 KB
#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

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);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Incorrect 1 ms 364 KB Output isn't correct
15 Incorrect 1 ms 364 KB Output isn't correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 66 ms 492 KB Output is correct
26 Incorrect 21 ms 364 KB Output isn't correct
27 Correct 10 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 41 ms 492 KB Output is correct
30 Correct 34 ms 384 KB Output is correct
31 Correct 1445 ms 876 KB Output is correct
32 Incorrect 203 ms 620 KB Output isn't correct
33 Correct 26 ms 364 KB Output is correct
34 Correct 26 ms 364 KB Output is correct
35 Correct 904 ms 1132 KB Output is correct
36 Correct 721 ms 1132 KB Output is correct
37 Execution timed out 1596 ms 876 KB Time limit exceeded
38 Execution timed out 1596 ms 1260 KB Time limit exceeded
39 Correct 1112 ms 748 KB Output is correct
40 Execution timed out 1591 ms 876 KB Time limit exceeded
41 Execution timed out 1596 ms 1004 KB Time limit exceeded
42 Execution timed out 1597 ms 1260 KB Time limit exceeded
43 Execution timed out 1586 ms 1260 KB Time limit exceeded
44 Execution timed out 1573 ms 1516 KB Time limit exceeded
45 Execution timed out 1586 ms 1772 KB Time limit exceeded
46 Execution timed out 1565 ms 2284 KB Time limit exceeded
47 Execution timed out 1578 ms 2028 KB Time limit exceeded
48 Execution timed out 1589 ms 2028 KB Time limit exceeded
49 Execution timed out 1572 ms 2284 KB Time limit exceeded
50 Execution timed out 1558 ms 1260 KB Time limit exceeded