QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626435#7311. Welcome to ICPCCamp 2017ucup-team4906#WA 32ms5684kbC++201.7kb2024-10-10 08:54:202024-10-10 08:54:20

Judging History

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

  • [2024-10-10 08:54:20]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:5684kb
  • [2024-10-10 08:54:20]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define N 200010

const int mod = int(1e9 + 7);

int n, m;
vector<int>vi[N];
int vst[N], p[N], q[N];
int P[N];
void sol()
{
    // cout << "??:" << n << ' ' << m << '\n';
    for (int i = 1; i <= m; i ++) vst[i] = -1;
    for (int i = 1; i <= n; i ++)
    {
        int k; cin >> k;
        while (k --) 
        {
            int x;
            cin >> x;
            vi[i].push_back(x);
        }
    }
    for (int i = 1; i <= m; i ++) cin >> p[i];
    for (int i = 1; i <= m; i ++) q[p[i]] = i;
    P[0] = 1;
    for (int i = 1; i <= m; i ++) P[i] = (P[i - 1] + P[i - 1]) % mod;

    set<int>S;
    for (int i = 1; i <= n; i ++)S.insert(i);

    int sum = 0, ans = 0;

    for (int t = 0;; t ++)
    {
        if (S.empty()) break;
        vector<int>era;
        vector<int>v;
        for (int i : S)
        {
            if (vi[i].size() <= t)era.push_back(i);
            else 
            {
                int x = vi[i][t];
                if (vst[x] == -1) 
                {
                    vst[x] = t;
                    v.push_back(x);
                }
            } 
        }
        for (int x : era)S.erase(x);
        int num = 0;
        for (int x : v)ans = (ans + P[num]) % mod, num ++;
        sum = (sum + P[num]) % mod;
    }
    for (int i = 1; i <= m; i ++) if (vst[i] == -1)ans = (ans + 1) % mod;
    cout << (ans + 1) % mod << '\n';
    for (int i = 1; i <= n; i ++) vi[i].clear();
    for (int i = 1; i <= m; i ++) vst[i] = -1;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int T = 1;
    // cin >> T;
    while (cin >> n >> m) sol();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5608kb

input:

2 3
2 1 3
3 2 1 3
2 1 3
0 3
1 2 3

output:

5
4

result:

ok 2 number(s): "5 4"

Test #2:

score: -100
Wrong Answer
time: 32ms
memory: 5684kb

input:

3 16
1 7
1 16
1 4
14 10 8 1 4 13 5 9 7 12 2 6 3 16 11 15
10 16
2 10 6
2 12 1
3 16 4 1
2 11 5
1 14
1 9
4 14 10 4 13
2 7 14
1 15
1 14
6 15 12 9 5 14 10 16 4 7 11 2 3 8 1 13
6 15
2 15 5
2 10 13
1 11
2 6 10
3 4 9 12
3 13 1 10
7 3 4 1 10 12 13 6 9 14 15 11 5 2 8
5 6
1 6
1 6
1 4
5 4 5 1 2 3
3 4 6 3
3 5 4 ...

output:

21
275
77
9
17
584
19
14
96
43
20
25
2
3
17
9
9
25
12
11
17
11
3
11
23
2
4
11
13
9
2
13
4
67
11
17
2
12
13
32
18
11
9
14
19
28
21
5
10
17
41
30
15
12
21
5
14
17
64
15
28
5
33
21
11
11
6
16
22
4
11
13
11
7
17
7
5
27
23
42
4
2
10
3
11
11
8
128
28
11
34
11
10
5
41
25
8
10
40
8
32
16
16
22
7
4
24
16
13
...

result:

wrong answer 1st numbers differ - expected: '62', found: '21'