답안 #72140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72140 2018-08-26T05:30:48 Z 김동현보다 잘함(#2226, tlwpdus) 초코쿠키 기계 (FXCUP3_chocolate) C++17
100 / 100
1157 ms 175660 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n, m, k, e, p;
pii que[300100];
int bad[300100];
int chk[300100];
vector<int> ans;
vector<int> lis[300100];

const int INF = 1e9;

char buf[50];
int main() {
    int i;

    scanf("%d%d%d",&n,&m,&k);
    for (i=0;i<m;i++) {
        int a;
        scanf("%d",&a); a--;
        bad[a] = 1;
    }
    for (i=0;i<k;i++) {
        int a, b;
        scanf("%d%d",&a,&b); a--; b--;
        lis[a].push_back(b);
        lis[b].push_back(a);
    }
    scanf("%d",&e);
    bool flag = true;
    int cnt = 0;
    for (i=0;i<e;i++) {
        scanf(" %s",buf);
        scanf(" %s",buf);
        int d;
        scanf("%d",&d); d--;
        scanf(" %s",buf);
        scanf(" %s",buf);
        if (buf[0]=='B') {
            if (!bad[d]) {
                que[p++] = pii(d,1);
                cnt++;
            }
        }
        else {
            que[p++] = pii(d,0);
            flag= false;
        }
    }
    if(flag) {
        for (i=0;i<n;i++) if (bad[i]) ans.push_back(i);
    }
    for (i=0;i<p;i++) {
        if (que[i].second) {
            for (int &v : lis[que[i].first]) chk[v]++;
        }
        else {
            for (int &v : lis[que[i].first]) chk[v]=-INF;
        }
    }
    //for (i=0;i<n;i++) printf("%d : %d\n",i+1,chk[i]);
    for (i=0;i<n;i++) {
        if (chk[i]==cnt&&!bad[i]) ans.push_back(i);
    }
    sort(ans.begin(),ans.end());
    printf("%d\n",ans.size());
    for (int &v : ans) printf("%d ",v+1);
    printf("\n");

    return 0;
}

Compilation message

chocolate.cpp: In function 'int main()':
chocolate.cpp:71:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",ans.size());
                   ~~~~~~~~~~^
chocolate.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
chocolate.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a); a--;
         ~~~~~^~~~~~~~~
chocolate.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a,&b); a--; b--;
         ~~~~~^~~~~~~~~~~~~~
chocolate.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&e);
     ~~~~~^~~~~~~~~
chocolate.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",buf);
         ~~~~~^~~~~~~~~~~
chocolate.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",buf);
         ~~~~~^~~~~~~~~~~
chocolate.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&d); d--;
         ~~~~~^~~~~~~~~
chocolate.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",buf);
         ~~~~~^~~~~~~~~~~
chocolate.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",buf);
         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 10 ms 7416 KB Output is correct
3 Correct 12 ms 7608 KB Output is correct
4 Correct 90 ms 11968 KB Output is correct
5 Correct 10 ms 11968 KB Output is correct
6 Correct 9 ms 11968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 728 ms 19656 KB Output is correct
2 Correct 176 ms 19656 KB Output is correct
3 Correct 385 ms 25716 KB Output is correct
4 Correct 827 ms 44276 KB Output is correct
5 Correct 458 ms 47640 KB Output is correct
6 Correct 75 ms 47640 KB Output is correct
7 Correct 909 ms 67388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 10 ms 7416 KB Output is correct
3 Correct 12 ms 7608 KB Output is correct
4 Correct 90 ms 11968 KB Output is correct
5 Correct 10 ms 11968 KB Output is correct
6 Correct 9 ms 11968 KB Output is correct
7 Correct 728 ms 19656 KB Output is correct
8 Correct 176 ms 19656 KB Output is correct
9 Correct 385 ms 25716 KB Output is correct
10 Correct 827 ms 44276 KB Output is correct
11 Correct 458 ms 47640 KB Output is correct
12 Correct 75 ms 47640 KB Output is correct
13 Correct 909 ms 67388 KB Output is correct
14 Correct 29 ms 67388 KB Output is correct
15 Correct 21 ms 67388 KB Output is correct
16 Correct 802 ms 74716 KB Output is correct
17 Correct 339 ms 74716 KB Output is correct
18 Correct 931 ms 99460 KB Output is correct
19 Correct 1065 ms 116812 KB Output is correct
20 Correct 1008 ms 130040 KB Output is correct
21 Correct 1157 ms 145976 KB Output is correct
22 Correct 936 ms 158240 KB Output is correct
23 Correct 1090 ms 175660 KB Output is correct