QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#445039#8581. 섬Bolatulu0 2ms5876kbC++203.8kb2024-06-15 23:09:192024-06-15 23:09:19

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 23:09:19]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:5876kb
  • [2024-06-15 23:09:19]
  • 提交

answer

// Bolatulu
#include <bits/stdc++.h>
#include "island.h"

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define kanagattandirilmagandiktarinizdan ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fx cout << fixed << setprecision(10);
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define len(v) (int)v.size()
#define bitcount(n) __builtin_popcountll(n)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define eb emplace_back
#define F first     
#define S second
#define T third
#define md (tl+tr)/2
#define TL v+v, tl,md
#define TR v+v+1, md+1,tr
#define Tl t[v].l, tl,md
#define Tr t[v].r, md+1,tr
#define yes cout << "YES\n"
#define no cout << "NO"
#define all(x) (x).begin(), (x).end()
#define cnk(n,k) mod(mod(f[(n)]*binpow(f[(n)-(k)],M-2))*binpow(f[(k)],M-2))
#define cnkf(n,k) mod(mod(f[(n)]*inv[(n)-(k)])*inv[(k)])
#define ank(n,k) mod(f[(n)]*binpow(f[(n)-(k)],M-2))
#define ankf(n,k) mod(f[(n)]*inv[(n)-(k)])
// #define int unsigned long long

#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

using namespace std;

const ll INF = 1e10;
const ll HZ = 1e5;
const int MAX = INT_MAX;
const int MIN = INT_MIN;
const db pi = 3.141592653;
const int P=31;

int M = 998244353;

struct segment{int l;int r;};
struct tree{int cnt;int mn;};
struct triple{int first;int second;int third;};

bool cmpt(triple a,triple b) {
    if (a.first != b.first)
        return a.first < b.first;
    if (a.second != b.second)
        return a.second > b.second;
    return a.third < b.third;
}

bool cmps(segment a,segment b) {
    if (a.r != b.r)
        return a.r < b.r;
    return a.l > b.l;
}

ll mod(ll a,ll b=M) {
    while (a < 0)
        a += M;
    return a % b;
}

ll binpow(ll a,ll n) {
    a = mod(a);
    if (!n)
        return 1;
    if (n & 1)
        return (a * binpow(a, n - 1)) % M;
    ll x = binpow(a, n >> 1);
    return (x * x) % M;
}

const int N=1e6+7;

int n,cnt[N];
vector <int> g[N];

void construct_two_trees(int N, vector<int> U, vector<int> V) {
    n=N;
    vector<array<int, 2> > t1,t2;
    for (int i=1;i<=2*n-3;i++) {
        int u,v;
        u=U[i-1]+1, v=V[i-1]+1;
        g[u].pb(v), g[v].pb(u);
    }
    set <pair <int,int>> s;
    for (int i=1;i<=n;i++) {
        cnt[i]=g[i].size();
        s.insert({cnt[i],i});
    }
    for (int i=1;i<n-3;i++) {
        int v=s.begin()->S;
        vector <int> fs;
        for (auto now : g[v]) {
            if (cnt[now]>0) {
                s.erase({cnt[now],now});
                fs.pb(now-1);
                cnt[now]--;
                s.insert({cnt[now],now});
            }
        }
        t1.pb({v-1,fs[0]}), t2.pb({v-1,fs[1]});
        s.erase({cnt[v],v});
        cnt[v]=0;
    }
    vector <int> sd;
    for (auto now : s) {
        sd.pb(now.S-1);
        // cout <<now.S << ' ';
    }
    int v=add_vertex(sd[0],sd[1],sd[2]);
    t1.pb({sd[0],sd[1]});
    t1.pb({sd[1],sd[2]});
    t1.pb({sd[2],v});
    t2.pb({sd[2],sd[0]});
    t2.pb({v,sd[0]});
    t2.pb({v,sd[1]});
    report(t1), report(t2);
}

#ifndef ONLINE_JUDGE

void solve() {
    int n;
    cin >> n;
    vector <int> v1,u1;
    for (int i=1;i<=2*n-3;i++) {
        int x,y;
        cin >> x >> y;
        v1.pb(x), u1.pb(y);
    }
    construct_two_trees(n,v1,u1);
}

signed main() {
    // file()
    kanagattandirilmagandiktarinizdan
    fx
    int test = 1;
    // cin >> test;
    for (int i=1;i<=test;i++) { 
        // cout << "Case " << i << ": ";
        solve();
        if (i<test)
            cout << '\n';
    }
    return 0;
}

#endif

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5876kb

input:

4
0 2

output:

1
3
1 3
3 2
2 4
2
3
2 1
4 1
4 3
1
1 3 2

result:

wrong answer Wrong Answer, wrong operation

Subtask #2:

score: 0
Runtime Error

Test #5:

score: 0
Runtime Error

input:

10
7 0
7 5
7 3
7 1
7 9
7 4
7 2

output:

Unauthorized output

result:


Subtask #3:

score: 0
Runtime Error

Test #10:

score: 0
Runtime Error

input:

5000
4593 3389
4593 1610
4593 2357
4593 3323
4593 2037
4593 3667
4593 2737
4593 2642
4593 3981
4593 2700
4593 2134
4593 1719
4593 1444
4593 3729
4593 1371
4593 546
4593 1249
4593 646
4593 4221
4593 1542
4593 2314
4735 4952
4593 680
4593 2555
4593 2152
4593 740
4593 4056
4593 64
4593 3079
4593 3021
4...

output:

Unauthorized output

result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%