| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 593311 | LucaGreg | Simple game (IZhO17_game) | C++17 | 1089 ms | 6800 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int sp[1000010];
int h[100010];
int main()
{
int n, m; scanf("%d %d", &n, &m);
scanf("%d", &h[1]);
for(int i=2;i<=n;i++){
scanf("%d", &h[i]);
sp[min(h[i-1], h[i])]++;
sp[max(h[i-1], h[i])+1]--;
}
for(int i=1;i<=1000001;i++){
sp[i] += sp[i-1];
}
for(int i=0;i<m;i++){
int t; scanf("%d", &t);
if(t==2){
int hq; scanf("%d", &hq);
printf("%d\n", sp[hq]);
}else if(t==1){
int pos, val; scanf("%d %d", &pos, &val);
if(pos==1){
//elimina a chain com o vertice seguinte
for(int j=min(h[pos], h[pos+1]);j<=max(h[pos], h[pos+1]);j++){
sp[j]--;
}
//cria a chain(com a nova altura) com o vertice seguinte
for(int j=min(val, h[pos+1]);j<=max(val, h[pos+1]);j++){
sp[j]++;
}
}else if(pos==n){
//elimina a chain com o vertice anterior
for(int j=min(h[pos], h[pos-1]);j<=max(h[pos], h[pos-1]);j++){
sp[j]--;
}
//cria a chain(com a nova altura) com o vertice anterior
for(int j=min(val, h[pos-1]);j<=max(val, h[pos-1]);j++){
sp[j]++;
}
}else{
//elimina a chain com o vertice seguinte
for(int j=min(h[pos], h[pos+1]);j<=max(h[pos], h[pos+1]);j++){
sp[j]--;
}
//elimina a chain com o vertice anterior
for(int j=min(h[pos], h[pos-1]);j<=max(h[pos], h[pos-1]);j++){
sp[j]--;
}
//cria a chain(com a nova altura) com o vertice seguinte
for(int j=min(val, h[pos+1]);j<=max(val, h[pos+1]);j++){
sp[j]++;
}
//cria a chain(com a nova altura) com o vertice anterior
for(int j=min(val, h[pos-1]);j<=max(val, h[pos-1]);j++){
sp[j]++;
}
}
h[pos] = val;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
