Submission #1049330

#TimeUsernameProblemLanguageResultExecution timeMemory
1049330Maite_MoraleMars (APIO22_mars)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define vll vector<ll> #define pll pair<ll,ll> #define F first #define S second vll v[500]; ll pass[500][500]; pll d[4]={{0,1},{1,0},{-1,0},{0,-1}}; void bfs(ll x,pll y){ queue<pll> q; q.push(y); pass[y.F][y.S]=1; while(!q.empty()){ pll u=q.front();q.pop(); for(auto d1 : d){ pll w=u;w.F+d1.F;w.S+=d1.S; if(min(w.F,w.S)<0 || max(w.F,w.S)>=x)continue; if(pass[w.F][w.S]==0 && v[w.F][w.S]==1){ q.push(w); pass[w.F][w.S]=1; } } } } /* 1 1 1 0 0 1 1 0 0 0 1 1 2 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 */ std::string process(std::vector <std::vector<std::string>> a, int I, int J, int k, int n) { //cout<<"\n"<<I<<" "<<J<<":"; ll vb=2*k+1; ll b=2*(k+1)+1; string s={}; if(k==n-1){ for(int i=0;i<b;i++){ v[i].assign(b,0LL); //cout<<'\n'; for(int j=0;j<b;j++){ ll bi=0,bj=0; if(i>=vb)bi=i-vb+1; if(j>=vb)bj=j-vb+1; ll d=(i-bi)*vb+j-bj; v[i][j]=a[bi][bj][d]-'0'; //cout<<i<<" "<<j<<":"<<bi<<" "<<bj<<" "<<vb<<"->"<<d<<"="<<(i-bi)*vb+j-bj<<":"<<v[i][j]<<"\n"; pass[i][j]=0; } } ll r=0; for(int i=0;i<b;i++){ for(int j=0;j<b;j++){ if(pass[i][j]==0 && v[i][j]==1){ //cout<<i<<" "<<j<<"\n"; r++;bfs(b,{i,j}); } } } //cout<<r<<":)"; for(int i=0;i<100;i++){ if(i<=10 && (r&(1LL<<i)))s+='1'; else s+='0'; } return s; } else{ for(int z=0;z<100;z++){ if(z<b*b){ ll i=z/b,j=z%b; ll bi=0,bj=0; if(i>=vb)bi=i-vb+1; if(j>=vb)bj=j-vb+1; s+=a[bi][bj][i-bi*vb+j-bj]; // if(j==0)cout<<"\n"; // cout<<s[z]<<" "; } else s+='0'; } return s; } }

Compilation message (stderr)

mars.cpp: In function 'void bfs(ll, std::pair<long long int, long long int>)':
mars.cpp:19:15: warning: statement has no effect [-Wunused-value]
   19 |    pll w=u;w.F+d1.F;w.S+=d1.S;
      |               ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...