Submission #63315355


Source Code Expand

// I AM A MUSLIM

#include "bits/stdc++.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define fast_io std::ios::sync_with_stdio(0);std::cin.tie(0)
#define lli long long int
#define flush fflush(stdout)
#define line printf("\n")
#define yn(a, b) printf("%s\n", (a) >= (b) ? "Yes":"No")
#define amodm(a, M) (((a)%M+M)%M)
// #define int lli

using pii = std::pair<int,int>;
using pis = std::pair<int,std::string>;

const int MOD = 1000000007;
const int mxN = 500100;

std::vector<int> g[mxN];
int deg[mxN], vis[mxN];

void dfs(int u, int &cnt) {
    if (vis[u]) return;
    cnt++;
    vis[u] = 1;
    if (deg[u] < 4) return;
    int taken = 0;
    std::vector<int> explore;
    for (auto &v : g[u]) {
        taken++;
        if (vis[v] == 0) explore.push_back(v);
        if (taken == 4) break;
    }
    for (auto &v : explore) dfs(v, cnt);
}

signed main() {
    int testCases=1;
    // scanf("%d",&testCases);
    
    for (int TC = 1; TC <= testCases; TC++) {
        int n;
        scanf("%d",&n);
        for (int i = 0; i < n-1; i++) {
            int u, v;
            scanf("%d%d",&u,&v);
            g[u].push_back(v);
            g[v].push_back(u);
            deg[u]++; deg[v]++;
        }

        for (auto &i : g) {
            sort(i.begin(), i.end(), [] (int a, int b){
                return deg[a] > deg[b];
            });
        }

        int ans = -1;
        for (int i = 1; i <= n; i++) {
            if (vis[i] || deg[i] < 4) continue;
            int cnt = 0;
            dfs(i, cnt);
            if (cnt > ans) ans = cnt;
        }

        printf("%d\n", ans);
        
    }
    
    return 0;
}

Submission Info

Submission Time
Task F - Alkane
User MArhamAA1422
Language C++ 20 (Clang 16.0.6)
Score 0
Code Size 1745 Byte
Status WA
Exec Time 100 ms
Memory 21828 KiB

Compile Error

./Main.cpp:5:13: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma GCC optimize("O3,unroll-loops")
            ^
./Main.cpp:6:13: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
            ^
./Main.cpp:19:11: warning: unused variable 'MOD' [-Wunused-const-variable]
const int MOD = 1000000007;
          ^
3 warnings generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 39
WA × 20
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All hand00.txt, hand01.txt, hand02.txt, hand03.txt, sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt, testcase44.txt, testcase45.txt, testcase46.txt, testcase47.txt, testcase48.txt, testcase49.txt, testcase50.txt, testcase51.txt
Case Name Status Exec Time Memory
hand00.txt AC 3 ms 3716 KiB
hand01.txt AC 3 ms 3664 KiB
hand02.txt AC 3 ms 3688 KiB
hand03.txt AC 3 ms 3800 KiB
sample00.txt AC 3 ms 3824 KiB
sample01.txt AC 3 ms 3820 KiB
sample02.txt AC 3 ms 3604 KiB
testcase00.txt AC 3 ms 3816 KiB
testcase01.txt AC 3 ms 3816 KiB
testcase02.txt AC 3 ms 3800 KiB
testcase03.txt AC 3 ms 3924 KiB
testcase04.txt AC 87 ms 15356 KiB
testcase05.txt AC 95 ms 16348 KiB
testcase06.txt AC 30 ms 8672 KiB
testcase07.txt AC 94 ms 16312 KiB
testcase08.txt AC 27 ms 8324 KiB
testcase09.txt AC 91 ms 16168 KiB
testcase10.txt AC 36 ms 11812 KiB
testcase11.txt AC 100 ms 21828 KiB
testcase12.txt AC 39 ms 10604 KiB
testcase13.txt AC 89 ms 16432 KiB
testcase14.txt AC 66 ms 13720 KiB
testcase15.txt AC 88 ms 16256 KiB
testcase16.txt AC 83 ms 15420 KiB
testcase17.txt AC 91 ms 16164 KiB
testcase18.txt AC 94 ms 16292 KiB
testcase19.txt AC 94 ms 16172 KiB
testcase20.txt AC 49 ms 10964 KiB
testcase21.txt AC 97 ms 16068 KiB
testcase22.txt AC 49 ms 11688 KiB
testcase23.txt AC 80 ms 15408 KiB
testcase24.txt AC 73 ms 14964 KiB
testcase25.txt AC 83 ms 15524 KiB
testcase26.txt AC 41 ms 10116 KiB
testcase27.txt AC 83 ms 15524 KiB
testcase28.txt AC 78 ms 14768 KiB
testcase29.txt AC 82 ms 15536 KiB
testcase30.txt AC 72 ms 14120 KiB
testcase31.txt AC 83 ms 15412 KiB
testcase32.txt WA 44 ms 10684 KiB
testcase33.txt WA 89 ms 16412 KiB
testcase34.txt WA 17 ms 6728 KiB
testcase35.txt WA 86 ms 16392 KiB
testcase36.txt WA 38 ms 10264 KiB
testcase37.txt WA 89 ms 16540 KiB
testcase38.txt WA 50 ms 11492 KiB
testcase39.txt WA 84 ms 16552 KiB
testcase40.txt WA 67 ms 14212 KiB
testcase41.txt WA 86 ms 16392 KiB
testcase42.txt WA 31 ms 9352 KiB
testcase43.txt WA 92 ms 16536 KiB
testcase44.txt WA 73 ms 14484 KiB
testcase45.txt WA 86 ms 16544 KiB
testcase46.txt WA 31 ms 9120 KiB
testcase47.txt WA 89 ms 16536 KiB
testcase48.txt WA 22 ms 7788 KiB
testcase49.txt WA 88 ms 16648 KiB
testcase50.txt WA 84 ms 15948 KiB
testcase51.txt WA 88 ms 16532 KiB