CODE FESTIVAL 2016 Final

Submission #992603

Source codeソースコード

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <limits>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define x first
#define y second
#define sf scanf
#define pf printf
#define vec vector
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define clr(a,b) memset(a,b,sizeof(a))
#define bin_cnt(x) __builtin_popcount(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define srep(sub,s) for(int sub=s&(s-1);sub;sub=(sub-1)&s)
#define irep(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define irrep(i,a) for(__typeof(a.rbegin()) i=a.rbegin();i!=a.rend();i++)
#define inf numeric_limits<int>::max()
#define finf numeric_limits<double>::infinity()
#define eps 1e-8
#pragma GCC optimize ("O3")
#define o3 __attribute__((optimize("O3")))
#pragma comment(linker, "/STACK:32505856")

template<class T> inline T sqr(T a) {return a*a;}
template<class T> inline int gmin(T&a,T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> inline int gmax(T&a,T b) {if(a<b){a=b;return 1;}return 0;}
inline int dcmp(const double &a) {return a>eps?1:(a<-eps?-1:0);}
struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}initializer;

#define N 200010
int dad[N];

int find_set(int x) {
    if (dad[x] == x) return x;
    return dad[x] = find_set(dad[x]);
}

void unif(int x,int y) {
    x = find_set(x);
    y = find_set(y);
    if (x != y) {
        dad[x] = y;
    }
}

int n, m, k;
int used[N];
int a;

int main() {
    sf("%d%d", &n, &m);

    rep(i,1,m) dad[i] = i;
    rep(i,1,n) {
        sf("%d", &k);

        int l1,l2;
        k--;
        sf("%d", &l1);
        used[l1] = 1;
        a = l1;

        while (k--) {
            sf("%d", &l2);
            used[l2] = 1;
            unif(l1, l2);
//            pf("<%d,%d>\n",l1,l2);
        }
    }

    rep(i,1,m)
        if (used[i])
        if (find_set(i) != find_set(a)) {
//            pf("dad[%d] = %d\n",i,dad[i]);
//            pf("dad[%d] = %d\n",a,dad[a]);
            pf("NO\n");
            return 0;
        }

    pf("YES\n");
    return 0;
}

Submission

Task問題 C - Interpretation
User nameユーザ名 alpc104
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 2493 Byte
File nameファイル名
Exec time実行時間 20 ms
Memory usageメモリ使用量 1152 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:70:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sf("%d%d", &n, &m);
^
./Main.cpp:74:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sf("%d", &k);
^
./Main.cpp:78:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sf("%d", &l1);
^
./Main.cpp:83:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
sf("%d", &l2);
^

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
dataset1 200 / 200 sample-01.txt,sample-02.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt
dataset2 200 / 200 sample-01.txt,sample-02.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt,02-01.txt,02-02.txt,02-03.txt,02-04.txt,02-05.txt,02-06.txt,02-07.txt,02-08.txt,02-09.txt,02-10.txt,02-11.txt,02-12.txt,02-13.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 3 ms 256 KB
01-02.txt AC 3 ms 256 KB
01-03.txt AC 3 ms 256 KB
01-04.txt AC 3 ms 256 KB
01-05.txt AC 3 ms 256 KB
01-06.txt AC 3 ms 256 KB
01-07.txt AC 3 ms 256 KB
01-08.txt AC 3 ms 256 KB
01-09.txt AC 3 ms 256 KB
01-10.txt AC 3 ms 256 KB
02-01.txt AC 17 ms 1024 KB
02-02.txt AC 18 ms 256 KB
02-03.txt AC 16 ms 640 KB
02-04.txt AC 20 ms 1024 KB
02-05.txt AC 18 ms 384 KB
02-06.txt AC 19 ms 1024 KB
02-07.txt AC 18 ms 384 KB
02-08.txt AC 17 ms 256 KB
02-09.txt AC 20 ms 640 KB
02-10.txt AC 17 ms 1152 KB
02-11.txt AC 17 ms 1152 KB
02-12.txt AC 16 ms 640 KB
02-13.txt AC 16 ms 640 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 3 ms 256 KB