UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214438#2386. 回忆erican304ms1168kbC++111.9kb2024-11-18 21:40:522024-11-19 08:35:22

answer

/*  Erica N  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define ull unsigned long long
#define pii pair<int, int>
#define ps second
#define pf first
#define itn int
#define rd read()
int read(){
    int xx = 0, ff = 1;char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')ff = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9')xx = xx * 10 + (ch - '0'), ch = getchar();
    return xx * ff;
}
// void write(int out) {
// 	if (out < 0)
// 		putchar('-'), out = -out;
// 	if (out > 9)
// 		write(out / 10);
// 	putchar(out % 10 + '0');
// }
#define cdbg(x...) do { cerr << #x << " -> "; err(x); } while (0)
void err() { cerr << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cerr << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }


const int N = 3e5 + 5;
const int INF = 1e18;
const int M = 1e7;
const int MOD = 1e9 + 7;

int p[N];
int a[N];
int vis[N];
int n;
int m;
bool check(){
	for(int i=1;i<=m;i++){
        vis[a[i]]=0;
    }
    for(int i=1;i<=m;i++){
        vis[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(!vis[p[i]+p[j]])return 0;
            vis[p[i]+p[j]]--;
        }
    }
    return 1;
}

void dfs(int x){
    if(x>n){
        if(check()){
            sort(p+1,p+n+1);
            for(int i=1;i<=n;i++){
                cout<<p[i]<<' ';
            }
            exit(0);
        }

        return ;
    }

    for(int i=0;i<=10;i++){
        p[x]=i;
        dfs(x+1);
    }
}

signed main() {
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
     n=rd;
    m=n*(n-1)/2;
    for(int i=1;i<=n*(n-1)/2;i++){
        a[i]=rd;
    }

    sort(a+1,a+m+1);

    dfs(1);

    

}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 1ms
memory: 1168kb

input:

5
4 5 9 9 10 13 14 14 15 19

output:

0 4 5 9 10 

result:

ok Your answer is correct.

Test #2:

score: 10
Accepted
time: 0ms
memory: 1168kb

input:

5
5 9 9 10 12 12 13 16 17 17

output:

1 4 8 8 9 

result:

ok Your answer is correct.

Test #3:

score: 10
Accepted
time: 3ms
memory: 1168kb

input:

5
10 11 12 13 13 14 15 15 16 17

output:

4 6 7 8 9 

result:

ok Your answer is correct.

Test #4:

score: 0
Time Limit Exceeded

input:

50
9 13 15 20 20 20 21 22 22 26 26 26 27 27 27 28 29 31 31 32 32 33 33 33 33 33 34 34 34 35 35 36 37...

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

50
9 11 14 14 16 16 16 18 19 19 21 21 21 21 22 22 23 23 23 23 24 25 25 26 26 26 26 26 26 26 27 27 27...

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

50
7 9 12 16 19 21 26 27 29 29 31 33 33 33 34 35 36 36 36 36 37 38 38 38 38 39 39 40 40 40 41 41 42 ...

output:


result:


Test #7:

score: 0
Runtime Error

input:

300
660422 717145 1052261 1191442 1526558 1583281 1636913 1972029 2028752 2207583 2247577 2427928 25...

output:


result:


Test #8:

score: 0
Runtime Error

input:

300
1719032 1728175 1968715 2265775 2506315 2515458 2534303 2752316 3002166 3035709 3071903 3081046 ...

output:


result:


Test #9:

score: 0
Runtime Error

input:

300
725653 809390 819383 974701 984694 1058923 1068431 1068916 1152653 1317964 1422171 1432164 15159...

output:


result:


Test #10:

score: 0
Runtime Error

input:

300
2355315 3132486 3240117 3325566 3662015 3854305 3961936 4047385 4053636 4142315 4383834 4725290 ...

output:


result: