제출 #887537

#제출 시각아이디문제언어결과실행 시간메모리
887537maxFedorchukT-Covering (eJOI19_covering)C++14
100 / 100
224 ms57900 KiB
#include <bits/stdc++.h> using namespace std; const int MX=1e6+10; vector < int > mas[MX]; int vis[MX]; int sm[MX]; int a[MX]; int n,m; int corx[4]={0,0,1,-1}; int cory[4]={1,-1,0,0}; vector < int > ver; int kver; int prd(int x,int y) { return (x*m+y); } void DFS(int zar) { if(sm[zar]) { kver++; } else { ver.push_back(a[zar]); } vis[zar]=1; for(auto u:mas[zar]) { if(!vis[u]) { DFS(u); } } return; } bool can_go(int x,int y) { return (0<=x && x<n && 0<=y && y<m); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>m; int zn; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>zn; a[prd(i,j)]=zn; } } int q,x,y; cin>>q; int res=0; for(int i=0;i<q;i++) { cin>>x>>y; res+=a[prd(x,y)]; sm[prd(x,y)]=1; for(int j=0;j<4;j++) { if(can_go(x+corx[j],y+cory[j])) { mas[prd(x,y)].push_back(prd(x+corx[j],y+cory[j])); mas[prd(x+corx[j],y+cory[j])].push_back(prd(x,y)); } } } for(int i=0;i<n*m;i++) { if(!vis[i] && sm[i]) { ver.clear(); kver=0; DFS(i); if(ver.size()<(3*kver)) { cout<<"No\n"; return 0; } sort(ver.begin(),ver.end()); reverse(ver.begin(),ver.end()); kver*=3; for(int i=0;i<kver;i++) { res+=ver[i]; } } } cout<<res<<"\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

covering.cpp: In function 'int main()':
covering.cpp:101:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |             if(ver.size()<(3*kver))
      |                ~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...