QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#719264#4740. Plan metranathan46900 13ms50596kbC++172.1kb2024-11-06 23:49:502024-11-06 23:49:50

Judging History

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

  • [2024-11-06 23:49:50]
  • 评测
  • 测评结果:0
  • 用时:13ms
  • 内存:50596kb
  • [2024-11-06 23:49:50]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define el cout << '\n'
#define f1(i,n) for(int i=1;i<=n;i++)
#define __file_name ""
using namespace std;
const ll maxn = 1e6+5, inf=1e18;

struct Edge{
    int u, v, w;
    Edge(){};
    Edge(int u, int v, int w): u(u), v(v), w(w){};
};

int n,d[maxn], l[maxn];
vector<int> mp[2*maxn], allv;
vector<Edge> ans;

bool cmp(int x, int y){
    return d[x] < d[y];
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    if(fopen(__file_name ".inp", "r")){
        freopen(__file_name ".inp","r",stdin);
        freopen(__file_name ".out","w",stdout);
    }
    // code here
    cin >> n;
    for(int i=2;i<n;i++) cin >> d[i];
    for(int i=2;i<n;i++) cin >> l[i];
    for(int i=2;i<n;i++){
        int diff = d[i] - l[i];
        if(mp[diff + maxn].empty()) allv.push_back(diff);
        mp[diff + maxn].push_back(i);
    }
    int duv = 1e9;
    for(int i=2;i<n;i++) duv = min(duv, d[i] + l[i]);
    if(mp[duv+maxn].empty()) allv.push_back(duv);
    if(mp[-duv+maxn].empty()) allv.push_back(-duv);
    mp[-duv+maxn].push_back(1); l[1] = duv;
    mp[duv+maxn].push_back(n); d[n] = duv;
    int rem2 = allv[0] & 1;
    for(int item: allv) {
        if((item & 1) != rem2) return cout << "NIE\n", 0;
        sort(mp[item + maxn].begin(), mp[item + maxn].end(), cmp);
    }
    sort(allv.begin(), allv.end());
    int pre = 1, dst = 0;
    for(int item: allv){
        int u = mp[item + maxn][0];
//        cout << item << ' ' << u << ' ' << d[u] << ' ' << dst << endl;
        if(u > 1){
            if(dst >= d[u]) return cout << "NIE\n", 0;
            ans.push_back(Edge(pre, u, d[u] - dst));
            dst = d[u];
            pre = u;
        }
        int dst2 = dst, pre2 = pre;
        for(int i=1;i<mp[item+maxn].size();i++){
            int v = mp[item+maxn][i];
            ans.push_back(Edge(pre2, v, d[v] - dst2));
            dst2 = d[v]; pre2 = v;
        }
    }
    cout << "TAK\n";
    for(Edge e: ans){
        cout << e.u << ' ' << e.v << ' ' << e.w << '\n';
    }
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 13ms
memory: 50520kb

input:

7
6 6 2 2 1
5 3 5 1 4

output:

TAK
1 6 1
6 4 1
1 5 2
5 2 4
5 7 1
7 3 3

result:

ok good solution

Test #2:

score: 11
Accepted
time: 0ms
memory: 50596kb

input:

10
31 89 20 19 19 20 19 164
70 88 20 20 20 19 20 125

output:

NIE

result:

ok no solution

Test #3:

score: 11
Accepted
time: 11ms
memory: 50508kb

input:

10
57 106 79 12 139 103 103 85
110 53 28 65 98 86 50 117

output:

NIE

result:

ok no solution

Test #4:

score: 11
Accepted
time: 4ms
memory: 50440kb

input:

10
13 62 24 125 13 15 54 94
1 76 14 113 1 1 68 82

output:

NIE

result:

ok no solution

Test #5:

score: 0
Wrong Answer
time: 4ms
memory: 50596kb

input:

10
123 146 139 5 192 80 77 118
97 172 165 31 166 106 51 92

output:

NIE

result:

wrong answer you didn't find a solution but jury did

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%