이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define pb push_back
#define N 200005
#define f first
#define s second
int n,m;
int yes;
vector<pair<int,int>> v;
int main(){
cin>>n>>m;
int arr[n+2][m+2],doldur[n+2][m+2],isaret[n+2][m+1];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>arr[i][j];
doldur[i][j]=0;
isaret[i][j]=0;
}
}
for(int i=1;i<=n;i++){
arr[i][0]=arr[i][n+1]=arr[0][i]=arr[n+1][i]=0;
isaret[i][0]=isaret[i][n+1]=isaret[0][i]=isaret[n+1][i]=0;
doldur[i][0]=doldur[i][n+1]=doldur[0][i]=doldur[n+1][i]=1;
}
int q;
ll int cev=0;
while(q--){
int x,y;cin>>x>>y;
x++;y++;
v.pb({x,y});
doldur[x][y]=2;
cev+=arr[x][y];
}
vector<pair<int,int>> bir={{1,0},{0,1},{-1,0},{0,-1}};
sort(v.begin(),v.end());
for(auto u:v){
int x=u.f,y=u.s;
int kac=0;
for(auto uwu:bir){
int ek1=uwu.f, ek2=uwu.s;
if(doldur[x+ek1][y+ek2]!=0)kac++;
}
if(kac<3){cout<<"No"<<endl;return 0;}
if(kac==3){
for(auto uwu:bir){
int ek1=uwu.f, ek2=uwu.s;
if(doldur[x+ek1][y+ek2]==0){
cev+=arr[x+ek1][y+ek2];
}
}
isaret[x][y]=1;
}
}
cout<<cev<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
covering.cpp: In function 'int main()':
covering.cpp:31:9: warning: 'q' is used uninitialized in this function [-Wuninitialized]
31 | while(q--){
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |