結果
| 問題 |
No.833 かっこいい電車
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-26 21:21:54 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,282 bytes |
| コンパイル時間 | 330 ms |
| コンパイル使用メモリ | 32,000 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-16 11:24:31 |
| 合計ジャッジ時間 | 6,205 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 WA * 2 |
ソースコード
#include <stdio.h>
int N,Q;
long int x;
int q;
struct train
{
long long int cool;
long long int setpoint;
int connected;
int alias;
};
int main(){
int modified=1;
scanf("%d %d",&N,&Q);
struct train t[N];
for(int i =0;i<N;i++){
scanf("%lld",&t[i].cool);
t[i].setpoint=t[i].cool;
t[i].connected=0;
t[i].alias=-1;
}
for(int i =0;i<Q;i++){
scanf("%d %ld",&q,&x);
if(q==1){
modified = 1;
t[x-1].connected=1;
//t[x].setpoint = t[x-1].setpoint+t[x].cool;
for(int j=x-1;j<N;j++){
if(t[j].connected == 1){
t[j+1].setpoint = t[j].setpoint+t[j+1].cool;
}
else{
break;
}
}
}
else if(q==2){
modified = 1;
//t[x].setpoint = t[x-1].setpoint-t[x].cool;
for(int j=x-1;j<N;j++){
if(t[j].connected == 1){
t[j+1].setpoint = t[j+1].setpoint-t[x-1].setpoint;
}
else{
break;
}
}
t[x-1].connected=0;
for(int j=0;j<=x;j++){t[j].alias=-1;}
}
else if(q==3){
modified = 1;
t[x-1].cool=t[x-1].cool + 1;
t[x-1].setpoint=t[x-1].setpoint + 1;
for(int j=x-1;j<N;j++){
if(t[j].connected == 1){
t[j+1].setpoint = t[j+1].setpoint + 1;
}
else{
break;
}
}
}
else if(q==4){
long long int res=0;
if (t[x-1].alias==-1){modified=1;}
if (modified==1){
int j;
for(j=x-1;j<N;j++){
if (t[j].connected ==0){
res=t[j].setpoint;
break;
}
}
for(int i=x-1;i<j;i++){
t[i].alias=j;
}
modified = 0;
}
else{
res=t[t[x].alias].setpoint;
}
printf("%lld\n",res);
}
}
return 0;
}