提出 #374265
ソースコード 拡げる
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
lli coss[100005]={};
int live[100005]={};
int tov[100005]={};
vector<mp> vs[100005];
int n;
void minco(int &p,int q){
if(p==-1)p=q;
else if(q!=-1 &&( coss[p]>coss[q] || (coss[p]==coss[q] && p>q)))p=q;
}
int dfs(int no,int p){
int res = -1;
rep(i,vs[no].size()){
int to = vs[no][i].fir,en = vs[no][i].sec;
if(to==p)continue;
if(live[en]==-1)continue;
int mine = dfs(to,no);
minco(res,mine);
minco(res,en);
}
//printf("dfs.. %d %d %d\n",no,p,res);
return res;
}
int main(void){
scanf("%d",&n);
reg(i,1,n-1){
int a,b;
lli c;
scanf("%d%d%lld",&a,&b,&c);
vs[a].push_back(mp(b,i));
vs[b].push_back(mp(a,i));
coss[i]=c;
tov[i]=a;
}
int iq;
scanf("%d",&iq);
if(n>1005 || iq>1005)return 0;
rep(i,iq){
int iiq;
scanf("%d",&iiq);
if(iiq==1){
int a; lli b;
scanf("%d%lld",&a,&b);
if(live[a]==-1)continue;
coss[a]+=b;
//printf("es .. %d %d %lld\n",a,live[a],coss[a]);
}
else{
int a;
scanf("%d",&a);
if(live[a]==-1){
printf("-1\n");
}
else{
int sv = tov[a];
int mine = dfs(sv,-100);
if(mine==-1){
mine=0;
mine=mine/mine;
}
printf("%d\n",mine);
live[mine]=-1;
}
}
}
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
I - 盆栽 |
| ユーザ |
SAT3 |
| 言語 |
C++ (GCC 4.9.2) |
| 得点 |
30 |
| コード長 |
1784 Byte |
| 結果 |
WA |
| 実行時間 |
110 ms |
| メモリ |
8212 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:54:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:58:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%lld",&a,&b,&c);
^
./Main.cpp:66:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&iq);
^
./Main.cpp:71:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&iiq);
^
./Main.cpp:74:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%lld",&a,&b);
^
./Mai...
ジャッジ結果
| セット名 |
Subtask |
All |
| 得点 / 配点 |
30 / 30 |
0 / 270 |
| 結果 |
|
|
| セット名 |
テストケース |
| Subtask |
atetubou-challenge1.in, subtask_00.txt, subtask_01.txt, subtask_02.txt, subtask_03.txt, subtask_04.txt, subtask_05.txt, subtask_06.txt, subtask_07.txt, subtask_08.txt, subtask_09.txt, subtask_10.txt, subtask_11.txt, subtask_12.txt, subtask_13.txt, subtask_14.txt, subtask_15.txt, subtask_16.txt |
| All |
scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt, scrambled_25.txt, scrambled_26.txt, scrambled_27.txt, scrambled_28.txt, scrambled_29.txt, scrambled_30.txt, scrambled_31.txt, scrambled_32.txt, subtask_00.txt, subtask_01.txt, subtask_02.txt, subtask_03.txt, subtask_04.txt, subtask_05.txt, subtask_06.txt, subtask_07.txt, subtask_08.txt, subtask_09.txt, subtask_10.txt, subtask_11.txt, subtask_12.txt, subtask_13.txt, subtask_14.txt, subtask_15.txt, subtask_16.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| scrambled_00.txt |
AC |
30 ms |
3108 KiB |
| scrambled_01.txt |
AC |
33 ms |
3108 KiB |
| scrambled_02.txt |
AC |
33 ms |
3100 KiB |
| scrambled_03.txt |
AC |
32 ms |
3232 KiB |
| scrambled_04.txt |
AC |
34 ms |
3108 KiB |
| scrambled_05.txt |
AC |
34 ms |
3104 KiB |
| scrambled_06.txt |
AC |
33 ms |
3228 KiB |
| scrambled_07.txt |
AC |
33 ms |
3100 KiB |
| scrambled_08.txt |
AC |
33 ms |
3104 KiB |
| scrambled_09.txt |
AC |
32 ms |
3112 KiB |
| scrambled_10.txt |
AC |
33 ms |
3228 KiB |
| scrambled_11.txt |
WA |
104 ms |
7964 KiB |
| scrambled_12.txt |
WA |
105 ms |
7964 KiB |
| scrambled_13.txt |
WA |
106 ms |
7976 KiB |
| scrambled_14.txt |
WA |
106 ms |
7968 KiB |
| scrambled_15.txt |
WA |
107 ms |
7972 KiB |
| scrambled_16.txt |
WA |
106 ms |
7968 KiB |
| scrambled_17.txt |
WA |
105 ms |
7960 KiB |
| scrambled_18.txt |
WA |
107 ms |
7952 KiB |
| scrambled_19.txt |
WA |
101 ms |
7972 KiB |
| scrambled_20.txt |
WA |
104 ms |
7964 KiB |
| scrambled_21.txt |
WA |
86 ms |
8212 KiB |
| scrambled_22.txt |
AC |
31 ms |
3096 KiB |
| scrambled_23.txt |
AC |
33 ms |
3108 KiB |
| scrambled_24.txt |
AC |
33 ms |
3104 KiB |
| scrambled_25.txt |
AC |
33 ms |
3108 KiB |
| scrambled_26.txt |
AC |
31 ms |
3104 KiB |
| scrambled_27.txt |
WA |
110 ms |
7972 KiB |
| scrambled_28.txt |
WA |
107 ms |
7972 KiB |
| scrambled_29.txt |
WA |
107 ms |
7964 KiB |
| scrambled_30.txt |
WA |
107 ms |
7964 KiB |
| scrambled_31.txt |
WA |
108 ms |
8024 KiB |
| scrambled_32.txt |
AC |
29 ms |
3228 KiB |
| subtask_00.txt |
AC |
29 ms |
3108 KiB |
| subtask_01.txt |
AC |
32 ms |
3100 KiB |
| subtask_02.txt |
AC |
32 ms |
3108 KiB |
| subtask_03.txt |
AC |
32 ms |
3108 KiB |
| subtask_04.txt |
AC |
32 ms |
3152 KiB |
| subtask_05.txt |
AC |
31 ms |
3104 KiB |
| subtask_06.txt |
AC |
33 ms |
3232 KiB |
| subtask_07.txt |
AC |
32 ms |
3232 KiB |
| subtask_08.txt |
AC |
32 ms |
3104 KiB |
| subtask_09.txt |
AC |
32 ms |
3104 KiB |
| subtask_10.txt |
AC |
31 ms |
3232 KiB |
| subtask_11.txt |
AC |
32 ms |
3116 KiB |
| subtask_12.txt |
AC |
32 ms |
3116 KiB |
| subtask_13.txt |
AC |
32 ms |
3232 KiB |
| subtask_14.txt |
AC |
32 ms |
3232 KiB |
| subtask_15.txt |
AC |
32 ms |
3112 KiB |
| subtask_16.txt |
AC |
29 ms |
3104 KiB |