Submission #72140

#TimeUsernameProblemLanguageResultExecution timeMemory
72140김동현보다 잘함 (#118)Chocolate Cookie Machine (FXCUP3_chocolate)C++17
100 / 100
1157 ms175660 KiB
#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 (stderr)

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);
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...