QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#359910#408. Dungeon 2jerzyk0 0ms0kbC++203.0kb2024-03-20 23:41:052024-03-20 23:41:06

Judging History

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

  • [2024-03-20 23:41:06]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-03-20 23:41:05]
  • 提交

answer

#include "dungeon2.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 300 + 7;
int p3[N];
int dis[N], ans[N];
int in[N], out[N];
int cur[N];
vector<int> ed[N], up[N], val[N];
vector<int> drz[N];
int cnt = 0;

void DoP3(int n)
{
    p3[0] = 1;
    for(int i = 1; i <= n; ++i)
        p3[i] = p3[i - 1] * 3;
}

void DFS(int v)
{
    int m = NumberOfRoads();
    in[v] = LastRoad();

    //cout << "dfs: " << v << " " << m << " " << in[v] << "\n";
    //cout << v << "\n";
    for(int i = 1; i <= m; ++i)
    {
        cout << v << " " << i << "\n";
        if(i == in[v]) continue;

        Move(i, 2);
        int cba = LastRoad();
        if(Color() == 2)
        {
            up[v].pb(i);
            val[v].pb(0);
            Move(cba, 2);
            continue;
        }
        if(Color() == 1)
        {
            ++cnt;
            int ne = cnt;
            ed[v].pb(ne); ed[ne].pb(v);
            drz[v].pb(ne);
            out[ne] = i;
        
            DFS(ne);
        }
        Move(cba, 3);
    }
}

void DFSR(int v, int r)
{
    for(int i = 0; i < (int)up[v].size(); ++i)
    {
        Move(up[v][i], 1);
        val[v][i] += p3[r] * (Color() - 1);
        Move(LastRoad(), Color());
    }
    for(int i = 0; i < (int)drz[v].size(); ++i)
    {
        Move(out[drz[v][i]], (cur[v] % 3) + 1);
        DFSR(drz[v][i], r);
        Move(in[drz[v][i]], 1);
    }
    cur[v] /= 3;
}

void BFS(int s)
{
    int v;
    queue<int> q;
    for(int i = 1; i <= cnt; ++i) dis[i] = cnt * 10;
    dis[s] = 0;
    q.push(s);
    while(q.size())
    {
        v = q.front(); q.pop();
        ++ans[dis[v]];
        for(int i = 0; i < ed[v].size(); ++i)
            if(dis[ed[v][i]] > dis[v] + 1)
            {
                dis[ed[v][i]] = dis[v] + 1;
                q.push(ed[v][i]);
            }
    }
}

void Inspect(int R)
{
    DoP3(6);
    cnt = 1;
    DFS(1);

    /*
    for(int i = 1; i <= cnt; ++i)
    {
        cout << "new: " << i << " " << drz[i].size() << " " << up[i].size() << "\ndrz: ";
        for(int j = 0; j < (int)drz[i].size(); ++j)
            cout << drz[i][j] << " ";
        cout << "\nup:";
        for(int j = 0; j < (int)up[i].size(); ++j)
            cout << up[i][j] << " ";
        cout << "\n";
    }*/

    for(int i = 1; i <= cnt; ++i)
        cur[i] = i;
    //for(int i = 0; i < 5; ++i)
        //DFSR(1, i);
    /*
    for(int i = 1; i <= cnt; ++i)
        for(int j = 0; j < (int)up[i].size(); ++j)
        {
            ed[i].pb(val[i][j]);
            ed[val[i][j]].pb(i);
        }
        */

    //for(int i = 1; i <= cnt; ++i)
        //BFS(i);


    for(int i = 1; i <= R; ++i)
        Answer(i, ans[i] / 2);
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

10 100 50
7
5 7 10 4 6 2 3
2
1 5
3
1 10 7
2
10 1
3
1 9 2
2
1 7
5
9 6 8 3 1
1
7
2
5 7
3
1 4 3
15
24
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

Unauthorized output

result:


Subtask #2:

score: 0
Runtime Error

Test #16:

score: 0
Runtime Error

input:

10 3 50
4
7 4 10 5
2
8 6
1
10
2
1 9
3
1 7 10
2
7 2
5
6 1 5 8 9
3
7 9 2
4
10 8 7 4
4
1 9 5 3
15
19
9
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

Unauthorized output

result:


Subtask #3:

score: 0
Runtime Error

Test #31:

score: 0
Runtime Error

input:

200 3 200
6
149 79 143 164 179 68
4
44 52 144 113
1
84
3
31 188 166
1
109
4
154 192 125 147
1
198
4
103 27 192 95
3
33 166 179
1
125
3
31 61 150
3
168 152 161
2
67 64
1
136
2
150 17
1
192
2
15 142
2
56 122
1
35
2
97 200
2
129 22
4
72 134 31 21
2
53 82
4
195 181 104 146
1
78
1
88
3
8 78 127
4
152 200...

output:

Unauthorized output

result: