提出 #60735862


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int H,W,R,C;
ll X,S[555][555];
int vis[555][555];
ll cur;

priority_queue<pair<ll,int>> Q;
void add(int y,int x) {
	cur+=S[y][x];
	int i;
	int d[]={0,1,0,-1};
	FOR(i,4) {
		int ty=y+d[i];
		int tx=x+d[i^1];
		if(ty<0||ty>=H||tx<0||tx>=W||vis[ty][tx]) continue;
		vis[ty][tx]=1;
		Q.push({-S[ty][tx],ty*1000+tx});
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>X;
	cin>>R>>C;
	R--,C--;
	FOR(y,H) FOR(x,W) cin>>S[y][x];
	
	add(R,C);
	vis[R][C]=1;
	while(Q.size()) {
		ll co=-Q.top().first;
		y=Q.top().second/1000;
		x=Q.top().second%1000;
		Q.pop();
		if((__int128)co*X>=cur) break;
		add(y,x);
		
	}
	cout<<cur<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

提出情報

提出日時
問題 E - Takahashi is Slime 2
ユーザ kmjp
言語 C++ 20 (gcc 12.2)
得点 450
コード長 1502 Byte
結果 AC
実行時間 51 ms
メモリ 10708 KiB

コンパイルエラー

Main.cpp: In function ‘void solve()’:
Main.cpp:36:13: warning: unused variable ‘i’ [-Wunused-variable]
   36 |         int i,j,k,l,r,x,y; string s;
      |             ^
Main.cpp:36:15: warning: unused variable ‘j’ [-Wunused-variable]
   36 |         int i,j,k,l,r,x,y; string s;
      |               ^
Main.cpp:36:17: warning: unused variable ‘k’ [-Wunused-variable]
   36 |         int i,j,k,l,r,x,y; string s;
      |                 ^
Main.cpp:36:19: warning: unused variable ‘l’ [-Wunused-variable]
   36 |         int i,j,k,l,r,x,y; string s;
      |                   ^
Main.cpp:36:21: warning: unused variable ‘r’ [-Wunused-variable]
   36 |         int i,j,k,l,r,x,y; string s;
      |                     ^
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:6:19: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                   ^~~
Main.cpp:61:9: note: in expansion of macro ‘FOR’
   61 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |         ^~~
Main.cpp:6:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                   ^~~
Main.cpp:61:45: note: in expansion of macro ‘FOR’
   61 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                             ^~~
Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
Main.cpp:61:45: note: in expansion of macro ‘FOR’
   61 |         FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                             ^~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 65
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_53.txt, 01_random_54.txt, 01_random_55.txt, 01_random_56.txt, 01_random_57.txt, 01_random_58.txt, 01_random_59.txt, 01_random_60.txt, 01_random_61.txt, 01_random_62.txt, 01_random_63.txt, 01_random_64.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3500 KiB
00_sample_01.txt AC 1 ms 3524 KiB
00_sample_02.txt AC 1 ms 3616 KiB
01_random_03.txt AC 48 ms 7668 KiB
01_random_04.txt AC 4 ms 5564 KiB
01_random_05.txt AC 51 ms 8404 KiB
01_random_06.txt AC 12 ms 5320 KiB
01_random_07.txt AC 50 ms 8500 KiB
01_random_08.txt AC 3 ms 4256 KiB
01_random_09.txt AC 51 ms 8488 KiB
01_random_10.txt AC 9 ms 5024 KiB
01_random_11.txt AC 16 ms 5660 KiB
01_random_12.txt AC 1 ms 3532 KiB
01_random_13.txt AC 16 ms 5688 KiB
01_random_14.txt AC 6 ms 5432 KiB
01_random_15.txt AC 48 ms 8316 KiB
01_random_16.txt AC 2 ms 4488 KiB
01_random_17.txt AC 49 ms 8440 KiB
01_random_18.txt AC 4 ms 4340 KiB
01_random_19.txt AC 47 ms 7472 KiB
01_random_20.txt AC 5 ms 4600 KiB
01_random_21.txt AC 48 ms 8588 KiB
01_random_22.txt AC 3 ms 4656 KiB
01_random_23.txt AC 16 ms 5608 KiB
01_random_24.txt AC 4 ms 4500 KiB
01_random_25.txt AC 16 ms 5660 KiB
01_random_26.txt AC 1 ms 3536 KiB
01_random_27.txt AC 14 ms 5584 KiB
01_random_28.txt AC 5 ms 5004 KiB
01_random_29.txt AC 16 ms 5624 KiB
01_random_30.txt AC 7 ms 4768 KiB
01_random_31.txt AC 16 ms 5624 KiB
01_random_32.txt AC 5 ms 4240 KiB
01_random_33.txt AC 16 ms 5688 KiB
01_random_34.txt AC 9 ms 4636 KiB
01_random_35.txt AC 15 ms 5744 KiB
01_random_36.txt AC 2 ms 3980 KiB
01_random_37.txt AC 14 ms 5756 KiB
01_random_38.txt AC 5 ms 5072 KiB
01_random_39.txt AC 16 ms 5688 KiB
01_random_40.txt AC 3 ms 5040 KiB
01_random_41.txt AC 16 ms 5684 KiB
01_random_42.txt AC 5 ms 4332 KiB
01_random_43.txt AC 1 ms 3632 KiB
01_random_44.txt AC 1 ms 3564 KiB
01_random_45.txt AC 1 ms 3568 KiB
01_random_46.txt AC 1 ms 3568 KiB
01_random_47.txt AC 1 ms 3508 KiB
01_random_48.txt AC 1 ms 3584 KiB
01_random_49.txt AC 1 ms 3516 KiB
01_random_50.txt AC 1 ms 3456 KiB
01_random_51.txt AC 1 ms 3520 KiB
01_random_52.txt AC 2 ms 6484 KiB
01_random_53.txt AC 2 ms 6516 KiB
01_random_54.txt AC 2 ms 6580 KiB
01_random_55.txt AC 2 ms 5508 KiB
01_random_56.txt AC 1 ms 5368 KiB
01_random_57.txt AC 2 ms 5500 KiB
01_random_58.txt AC 25 ms 10648 KiB
01_random_59.txt AC 27 ms 10708 KiB
01_random_60.txt AC 26 ms 10432 KiB
01_random_61.txt AC 1 ms 3436 KiB
01_random_62.txt AC 1 ms 3368 KiB
01_random_63.txt AC 1 ms 3564 KiB
01_random_64.txt AC 1 ms 3576 KiB