题目链接
为什么这个csp认证有输入输出,又看不到哪里错了啊,人都快炸了。
#include<bits/stdc++.h>
using namespace std;
# define N 10000
int main(){
int m,n;
cin>>n>>m;
int res1[N] = {0} ;
int res2[N] = {0} ;
int dep[N] = {0};
int day[N] = {0};
for(int i = 1 ; i <= m ; ++i){
cin>>dep[i];
}
for(int i = 1 ; i <= m ; ++i){
cin>>day[i];
}
bool flag = false;
for(int i = m ; i >= 1 ; --i){
int t = 0 ;
t+= day[i];
if(dep[i]!=0){
int j = i ;
while(dep[j] != 0){
int d = dep[j];
t += day[d];
j = d;
}
if(t > n){
flag = true;
}else {
res2[i] = n - t + 1;
}
}else{
res2[i] = n - t + 1;
}
res1[i] = t - day[i] + 1;
}
for(int i =1 ; i <= m - 1 ; ++i){
cout<<res1[i]<<" ";
}
cout<< res1[m] ;
if(!flag){
cout<<endl;
for(int i =1 ; i <= m - 1 ; ++i){
cout<<res2[i]<<" ";
}
cout<<res2[m];
}
// test:
// cout<<"------"<<endl;
// for(int i =1 ; i <= m - 1 ; ++i){
// cout<<res2[i]<<" ";
//
// }
// cout<< res2[m] ;
return 0;
}我交的一直70%,这什么ccf,草?




