QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425173 | #8724. September | neilliu | 0 | 0ms | 0kb | C++14 | 2.2kb | 2024-05-29 23:26:02 | 2024-05-29 23:26:02 |
answer
#include<bits/stdc++.h>
#include "september.h"
using namespace std;
#define MAXN 100005
#define MAXM 6
int dep[MAXN];
vector<int> edge[MAXN];
int F[MAXN],S[MAXM][MAXN];
int sum[MAXM][MAXN];//xia mian you ji ge dian zai xu lie li
int status[MAXM][MAXN];//mu qian zhuang kuang
bool ok[MAXM][MAXN];
int nowin[MAXM][MAXN];
void dfs1(int now){//calcu dep
dep[now] = 1;
for(int i = 0; i < edge[now].size(); i++){
if(edge[now][i] == F[now]) continue;
dfs1(edge[now][i]);
dep[now] += dep[edge[now][i]];
}
}
int solve(int n,int m,vector<int> f,vector< vector<int> > s){
for(int i = 0; i < n; i++) F[i] = f[i];
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++) S[i][j] = s[i][j];
}
memset(dep,0,sizeof(dep));
memset(sum,0,sizeof(sum));
memset(status,0,sizeof(status));
memset(ok,0,sizeof(ok));
memset(nowin,0,sizeof(nowin));
//for(int i = 0; i < n; i++) edge[i].clear();
for(int i = 1; i < n; i++){
edge[i].push_back(F[i]);
edge[F[i]].push_back(i);
}
dfs1(0);
for(int i = 0; i < n-1; i++){//mei ju di i tian
for(int j = 0; j < m; j++){
int dian = S[j][i];
while(1){
if(dian == 0) break;
if(status[j][dian] == 0) status[j][dian] = -1,status[j][n]--,sum[j][dian]++;
if(sum[j][dian] == dep[dian]){
status[j][dian] = 1;
status[j][n] += 2;
sum[j][F[dian]] += sum[j][dian];
dian = F[dian];
}else break;
}
if(sum[j][n] == i+1) ok[j][i] = 1;
else ok[j][i] = 0;
}
}
int ans = 0;
for(int i = 0; i < n-1; i++){
for(int j = 0; j < m; j++){
nowin[j][S[j][i]] = 1;
}
bool ok1 = 1;
for(int j = 0; j < m; j++){
int count = 0;
for(int jj = 0; jj < m; jj++) count += nowin[jj][S[j][i]];
if(count != m){
ok1 = 0; break;
}
}
if(ok1 == 0) continue;
int count = 0;
for(int j = 0; j < m; j++) if(ok[j][i] == 1) count++;
if(count == m) ans++;
}
return ans + 1;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Memory Limit Exceeded
Test #1:
score: 0
Memory Limit Exceeded
input:
txy4h26c1rm1uv8tr3eonahd67u8h56x 4 7 1 0 0 2 3 3 5 1 6 4 3 5 2 10 1 0 1 2 0 3 0 5 4 8 9 7 6 8 4 5 3 2 1 7 1 0 0 0 1 3 0 2 4 1 6 5 3 6 1 0 0 1 1 3 4 5 2 3 1
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Time Limit Exceeded
Test #17:
score: 0
Time Limit Exceeded
input:
txy4h26c1rm1uv8tr3eonahd67u8h56x 53 10 1 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 10 1 0 1 2 3 4 5 6 7 8 9 7 8 5 6 4 3 2 1 10 1 0 1 2 3 4 5 6 7 8 8 9 7 5 6 3 2 4 1 10 1 0 1 2 3 4 5 6 7 8 8 9 6 7 5 4 3 2 1 10 1 0 1 2 3 4 5 6 7 8 8 9 7 5 6 3 4 2 1 10 1 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 2 3 1 10 1 0 1 2 3 4 5 6...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #3:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%
Subtask #9:
score: 0
Skipped
Dependency #3:
0%
Subtask #10:
score: 0
Skipped
Dependency #1:
0%