Submission #498480

#TimeUsernameProblemLanguageResultExecution timeMemory
498480uncriptedT-Covering (eJOI19_covering)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define f first #define se second #define pb push_back using namespace std; int ss=0; int size=0; multiset<int> t; int nsize=0; int a[10000][10000]; int r[10000][10000]; int fix[10000][10000]; int gr[10000][10000]; int vis[10000][10000]; vector<pair<int,int> > adj[10000][10000]; void dfs(pair<int,int> p){ vis[p.f][p.se]=1; nsize++; if(vis[p.f-1][p.se]!=1){ size++; } if(vis[p.f+1][p.se]!=1){ size++; } if(vis[p.f][p.se-1]!=1){ size++; } if(vis[p.f][p.se+1]!=1){ size++; } t.insert(a[p.f-1][p.se]); t.insert(a[p.f+1][p.se]); t.insert(a[p.f][p.se-1]); t.insert(a[p.f][p.se+1]); vis[p.f-1][p.se]=1; vis[p.f+1][p.se]=1; vis[p.f][p.se-1]=1; vis[p.f][p.se+1]=1; for(int i=0; i<adj[p.f][p.se].size(); i++){ if(vis[adj[p.f][p.se][i].f][adj[p.f][p.se][i].se]){ continue; } dfs({adj[p.f][p.se][i].f, adj[p.f][p.se][i].se}); } } int main(){ int n,m; cin>>n>>m; for(int i=0; i<n; i++){ for (int j=0; j<m; j++){ cin>>a[i][j]; r[i][j]=0; fix[i][j]=0; gr[i][j]=0; vis[i][j]=0; } } int k; cin>>k; pair<int,int> c[k]; for(int i=0; i<k; i++){ cin>>c[i].f>>c[i].se; r[c[i].f][c[i].se]=1; } int pas=0; pair<int,int> d[8]={{1,1}, {1,0}, {1,-1}, {0,1}, {0, -1}, {-1,1}, {-1, 0}, {-1,-1}}; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ int p=0; for(int ii=0; ii<8; ii++){ int x=i+d[ii].f; int y=j+d[ii].se; if(r[i][j]==1 && r[x][y]==1){ p++; if(i+1>=n || i-1<0 || j-1<0 || j+1>=m || x+1>=n || x-1<0 || y-1<0 || y+1>=m){ cout<<"No"<<endl; return 0; } fix[i][j]=1; fix[i+1][j]=1; fix [i-1][j]=1; fix[i][j-1]=1; fix[i][j+1]=1; fix[x][y]=1; fix[x+1][y]=1; fix[x-1][y]=1; fix[x][y-1]=1; fix[x][y+1]=1; } } if(p>1){ cout<<"No"<<endl; return 0; } } } for(int asd=0; asd<k; asd++){ for(int i=0; i<k; i++){ int x=c[i].f,y=c[i].se; if(fix[x][y]==1){ continue; } int bruh=4; bool left=true,right=true,up=true,down=true; if(x+1>=n){ bruh--; up=false; }else if(fix[x+1][y]==1 || r[x+1][y]==1){ bruh--; up=false; } if(x-1<0){ bruh--; down=false; }else if(fix[x-1][y]==1 || r[x-1][y]==1){ bruh--; down=false; } if(y-1<0){ bruh--; left=false; }else if(fix[x][y-1]==1 || r[x][y-1]==1){ bruh--; left=false; } if( y+1>=m){ bruh--; right=false; }else if(fix[x][y+1]==1 || r[x][y+1]==1){ bruh--; right=false; } if(bruh==3){ fix[x][y]=1; if(up==true){ fix[x+1][y]=1; } if(down==true){ fix[x-1][y]=1; } if(left==true){ fix[x][y-1]=1; } if(right==true){ fix[x][y+1]=1; } } if(bruh<3){ cout<<"No"; return 0; } if(bruh==4){ gr[x][y]=1; } } } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ if(gr[i][j]==0){ continue; } if(i+2<n){ if(gr[i+2][j]==1){ adj[i][j].pb({i+2,j}); } } if(i-2>=0){ if(gr[i-2][j]==1){ adj[i][j].pb({i-2,j}); } } if(j+2<m){ if(gr[i][j+2]==1){ adj[i][j].pb({i,j+2}); } } if(j-2>=0){ if(gr[i][j-2]==1){ adj[i][j].pb({i,j-2}); } } } } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ if(vis[i][j]==0 && gr[i][j]==1 ){ dfs({i,j}); if(size==3*nsize+1){ ss+=*t.begin(); } if(size<3*nsize){ cout<<"No"<<endl; return 0; } t.clear(); } } } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ if(fix[i][j]==1 || vis[i][j]==1){ pas+=a[i][j]; } } } cout<<pas-ss; }

Compilation message (stderr)

covering.cpp: In function 'void dfs(std::pair<int, int>)':
covering.cpp:22:3: error: reference to 'size' is ambiguous
   22 |   size++;
      |   ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from covering.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
covering.cpp:8:5: note:                 'int size'
    8 | int size=0;
      |     ^~~~
covering.cpp:25:3: error: reference to 'size' is ambiguous
   25 |   size++;
      |   ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from covering.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
covering.cpp:8:5: note:                 'int size'
    8 | int size=0;
      |     ^~~~
covering.cpp:28:3: error: reference to 'size' is ambiguous
   28 |   size++;
      |   ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from covering.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
covering.cpp:8:5: note:                 'int size'
    8 | int size=0;
      |     ^~~~
covering.cpp:31:3: error: reference to 'size' is ambiguous
   31 |   size++;
      |   ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from covering.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
covering.cpp:8:5: note:                 'int size'
    8 | int size=0;
      |     ^~~~
covering.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i=0; i<adj[p.f][p.se].size(); i++){
      |               ~^~~~~~~~~~~~~~~~~~~~~~
covering.cpp: In function 'int main()':
covering.cpp:203:8: error: reference to 'size' is ambiguous
  203 |     if(size==3*nsize+1){
      |        ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from covering.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
covering.cpp:8:5: note:                 'int size'
    8 | int size=0;
      |     ^~~~
covering.cpp:206:8: error: reference to 'size' is ambiguous
  206 |     if(size<3*nsize){
      |        ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from covering.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
covering.cpp:8:5: note:                 'int size'
    8 | int size=0;
      |     ^~~~