Submission #339342

#TimeUsernameProblemLanguageResultExecution timeMemory
339342beksultan04Riddick's Cube (IZhO13_riddicks)C++14
0 / 100
379 ms65536 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-15 const int N = 1e5+12,INF=1e9+7; int n,m; map <pair <int, vector <vector <int> > > ,int> mp; deque <pair <int, vector <vector <int> > > >q; bool is_row(vector <vector <int> >v){ int i,j; for (i=0;i<v.size();++i){ for (j=1;j<v[i].size();++j){ if (v[i][j] != v[i][j-1])ret 0; } } ret 1; } bool is_columm(vector <vector <int> >v){ int i,j; for (i=1;i<v.size();++i){ for (j=0;j<v[i].size();++j){ if (v[i][j] != v[i-1][j])ret 0; } } ret 1; } void fun1 (vector <int> &v){ vector <int> p; for (int j=0;j<m;++j){ p.pb(v[j]); } for (int j=0;j<m;++j){ v[j] = p[(j+1)%m]; } } void fun2 (vector <int> &v){ vector <int> p; for (int j=0;j<m;++j){ p.pb(v[j]); } for (int j=0;j<m;++j){ v[j] = p[((j-1)+m)%m]; } } pair <int,vector <vector <int> >>fun3 (pair <int,vector <vector <int> >>v,int j){ vector <int> p; for (int i=0;i<n;++i){ p.pb(v.sc[i][j]); } for (int i=0;i<n;++i){ v.sc[i][j] = p[((i+1)+n)%n]; } ret v; } pair <int,vector <vector <int> >> fun4(pair <int,vector <vector <int> >>v,int j){ vector <int> p; for (int i=0;i<n;++i){ p.pb(v.sc[i][j]); } for (int i=0;i<n;++i){ v.sc[i][j] = p[((i-1)+n)%n]; } ret v; } main(){ pair <int,vector <vector <int> >>v; scan2(n,m) v.sc.resize(n); int i,j; for (i=0;i<n;++i){ v.sc[i].resize(m); for (j=0;j<m;++j){ scan1(v.sc[i][j]) } } v.fr =1; mp[v]=1; q.pb(v); int h=0; while (!q.empty()){ pair <int,vector <vector <int> >> t = q[0]; q.pop_front(); if (mp[t] == 100500)break; if (is_row(t.sc) || is_columm(t.sc)){ cout <<mp[t]-1; ret 0; } if (t.fr == 1){ for (i=0;i<m;++i){ { pair <int,vector <vector <int> >> to = fun3(t,i); if (!mp[to]){ mp[to] = mp[t]+1; q.pb(to); } } { pair <int,vector <vector <int> >> to = fun4(t,i); if (!mp[to]){ mp[to] = mp[t]+1; q.pb(to); } } } } for (i=0;i<t.sc.size();++i){ { pair <int,vector <vector <int> >> to = t; fun1(to.sc[i]); to.fr = 2; if (!mp[to] && !mp[{1,to.sc}]){ mp[to] = mp[t]+1; q.pb(to); } } { pair <int,vector <vector <int> >> to = t; fun2(to.sc[i]); to.fr = 2; if ( !mp[to] && !mp[{1,to.sc}]){ mp[to] = mp[t]+1; q.pb(to); } } } } cout <<100500; }

Compilation message (stderr)

riddicks.cpp: In function 'bool is_row(std::vector<std::vector<long long int> >)':
riddicks.cpp:27:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (i=0;i<v.size();++i){
      |              ~^~~~~~~~~
riddicks.cpp:28:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (j=1;j<v[i].size();++j){
      |                  ~^~~~~~~~~~~~
riddicks.cpp: In function 'bool is_columm(std::vector<std::vector<long long int> >)':
riddicks.cpp:36:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (i=1;i<v.size();++i){
      |              ~^~~~~~~~~
riddicks.cpp:37:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (j=0;j<v[i].size();++j){
      |                  ~^~~~~~~~~~~~
riddicks.cpp: At global scope:
riddicks.cpp:88:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   88 | main(){
      |      ^
riddicks.cpp: In function 'int main()':
riddicks.cpp:130:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  130 |         for (i=0;i<t.sc.size();++i){
      |                  ~^~~~~~~~~~~~
riddicks.cpp:103:9: warning: unused variable 'h' [-Wunused-variable]
  103 |     int h=0;
      |         ^
riddicks.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
riddicks.cpp:90:5: note: in expansion of macro 'scan2'
   90 |     scan2(n,m)
      |     ^~~~~
riddicks.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
riddicks.cpp:96:13: note: in expansion of macro 'scan1'
   96 |             scan1(v.sc[i][j])
      |             ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...