#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int > pii;
typedef long long int lld;
#define pi acos(-1)
#define fr(i,m,n) for(i=m;i<n;i++)
#define fu(i,m,n) for(i=m;i>=n;i--)
#define vec vector<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define all(v) v.begin(),v.end()
#define mom(ara) memset(ara,0,sizeof(ara));
#define m1m(ara) memset(ara,-1,sizeof(ara));
#define endl "\n"
#define eps 1.19209e-07
int encode (int n, int x, int y) {
vec code[1000];
int mask,i,j,cnt=1,z;
fr(mask,0,(1<<12))
{
vec h;
if(__builtin_popcount(mask)!=6) continue;
fr(i,0,12)
{
if(mask&(1<<i)) code[cnt].pb(i+1);
}
cnt++;
}
z=code[x].size();
while(1){
fr(j,0,code[y].size())
{
if(code[x][z-1]==code[y][j])
{
code[x].pp;
z--;
break;
}
}
if(j==code[y].size()) break;
}
return code[x][0];
}
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int > pii;
typedef long long int lld;
#define pi acos(-1)
#define fr(i,m,n) for(i=m;i<n;i++)
#define fu(i,m,n) for(i=m;i>=n;i--)
#define vec vector<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define all(v) v.begin(),v.end()
#define mom(ara) memset(ara,0,sizeof(ara));
#define m1m(ara) memset(ara,-1,sizeof(ara));
#define endl "\n"
#define eps 1.19209e-07
int decode (int n, int q, int h) {
vec code[1000];
int mask,i,j,cnt=1;
fr(mask,0,(1<<12))
{
vec h;
if(__builtin_popcount(mask)!=6) continue;
fr(i,0,12)
{
if(mask&(1<<i)) code[cnt].pb(i+1);
}
cnt++;
}
fr(i,0,code[q].size())
{
if(code[q][i]==h) return 1;
}
return 0;
}
Compilation message
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:6:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
6 | #define fr(i,m,n) for(i=m;i<n;i++)
......
34 | fr(j,0,code[y].size())
| ~~~~~~~~~~~~~~~~~~
encoder.cpp:34:4: note: in expansion of macro 'fr'
34 | fr(j,0,code[y].size())
| ^~
encoder.cpp:43:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if(j==code[y].size()) break;
| ~^~~~~~~~~~~~~~~~
decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:6:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
6 | #define fr(i,m,n) for(i=m;i<n;i++)
......
31 | fr(i,0,code[q].size())
| ~~~~~~~~~~~~~~~~~~
decoder.cpp:31:3: note: in expansion of macro 'fr'
31 | fr(i,0,code[q].size())
| ^~
decoder.cpp:20:14: warning: unused variable 'j' [-Wunused-variable]
20 | int mask,i,j,cnt=1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7075 ms |
868 KB |
Time limit exceeded |
2 |
Execution timed out |
7047 ms |
892 KB |
Time limit exceeded |