Submission #252167

# Submission time Handle Problem Language Result Execution time Memory
252167 2020-07-24T13:37:32 Z uacoder123 Konstrukcija (COCI20_konstrukcija) C++14
110 / 110
3 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <int> vi;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli k;
  cin>>k;
  int s,m=3;
  if(k>=0)
    s=1;
  else
    s=-1;
  k=abs(k);
  vi al[1001];
  al[999].pb(1000);
  al[998].pb(1000);
  al[997].pb(1000);
  int c=999;
  for(int i=0;i<64;++i)
  {
    c-=3;
    al[c].pb(c+3);
    al[c].pb(c+2);
    al[c].pb(c+1);
    al[c-1].pb(c+3);
    al[c-1].pb(c+2);
    al[c-1].pb(c+1);
    al[c-2].pb(c+3);
    al[c-2].pb(c+2);
    al[c-2].pb(c+1);
    m+=9;
  }
  c-=3;
  int mb=-1,b=0;
  while((1LL<<b)<=k)
  {
    if(bit(k,b))
      mb=b;
    b++;
  }
  if(mb%2==0&&mb>=0)
  {
    int f=(997-(mb*3));
    if(s==1)
    {
      al[1].pb(f);
      al[1].pb(f+1);
      m+=2;
    }
    else
    {
      for(int i=0;i<al[f].size();++i)
        al[1].pb(al[f][i]);
      m+=al[f].size();
    }
  }
  else if(mb>=0)
  {
    int f=(997-(mb*3));
    if(s==-1)
    {
      al[1].pb(f);
      al[1].pb(f+1);
      m+=2;
    }
    else
    {
      for(int i=0;i<al[f].size();++i)
        al[1].pb(al[f][i]);
      m+=al[f].size();
    }
  }
  for(int i=0;i<mb;++i)
  {
    if(bit(k,i))
    {
      int f=(997-(i)*3);
      if(i%2==0)
      {
        if(s==1)
        {
          for(int j=0;j<al[f].size();++j)
            al[c].pb(al[f][j]);
          al[1].pb(c);
          c--;
          m+=al[f].size()+1;
        }
        else
        {
          al[c].pb(f);
          al[c].pb(f+1);
          al[1].pb(c);
          c--;
          m+=3;
        }
      }
      else
      {
       if(s==-1)
        {
          for(int j=0;j<al[f].size();++j)
            al[c].pb(al[f][j]);
          al[1].pb(c);
          c--;
          m+=al[f].size()+1;
        }
        else
        {
          al[c].pb(f);
          al[c].pb(f+1);
          al[1].pb(c);
          c--;
          m+=3;
        } 
      }
    }
  }
  cout<<1000<<' '<<m<<endl;
  for(int i=1;i<=1000;++i)
  {
    for(int j=0;j<al[i].size();++j)
      cout<<i<<' '<<al[i][j]<<endl;
  }
  return 0;
}

Compilation message

konstrukcija.cpp: In function 'int main()':
konstrukcija.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i=0;i<al[f].size();++i)
                   ~^~~~~~~~~~~~~
konstrukcija.cpp:82:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i=0;i<al[f].size();++i)
                   ~^~~~~~~~~~~~~
konstrukcija.cpp:96:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           for(int j=0;j<al[f].size();++j)
                       ~^~~~~~~~~~~~~
konstrukcija.cpp:115:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           for(int j=0;j<al[f].size();++j)
                       ~^~~~~~~~~~~~~
konstrukcija.cpp:135:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<al[i].size();++j)
                 ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Correct.
2 Correct 2 ms 256 KB Correct.
3 Correct 3 ms 384 KB Correct.
4 Correct 2 ms 384 KB Correct.
5 Correct 2 ms 384 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Correct.
2 Correct 2 ms 384 KB Correct.
3 Correct 2 ms 512 KB Correct.
4 Correct 2 ms 384 KB Correct.
5 Correct 1 ms 384 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Correct.
2 Correct 2 ms 256 KB Correct.
3 Correct 3 ms 384 KB Correct.
4 Correct 2 ms 384 KB Correct.
5 Correct 2 ms 384 KB Correct.
6 Correct 2 ms 384 KB Correct.
7 Correct 2 ms 384 KB Correct.
8 Correct 2 ms 512 KB Correct.
9 Correct 2 ms 384 KB Correct.
10 Correct 1 ms 384 KB Correct.
11 Correct 1 ms 384 KB Correct.
12 Correct 2 ms 384 KB Correct.
13 Correct 2 ms 256 KB Correct.
14 Correct 2 ms 384 KB Correct.
15 Correct 2 ms 416 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Correct.
2 Correct 2 ms 256 KB Correct.
3 Correct 3 ms 384 KB Correct.
4 Correct 2 ms 384 KB Correct.
5 Correct 2 ms 384 KB Correct.
6 Correct 2 ms 384 KB Correct.
7 Correct 2 ms 384 KB Correct.
8 Correct 2 ms 512 KB Correct.
9 Correct 2 ms 384 KB Correct.
10 Correct 1 ms 384 KB Correct.
11 Correct 1 ms 384 KB Correct.
12 Correct 2 ms 384 KB Correct.
13 Correct 2 ms 256 KB Correct.
14 Correct 2 ms 384 KB Correct.
15 Correct 2 ms 416 KB Correct.
16 Correct 2 ms 384 KB Correct.
17 Correct 2 ms 384 KB Correct.
18 Correct 2 ms 384 KB Correct.
19 Correct 2 ms 384 KB Correct.
20 Correct 2 ms 384 KB Correct.
21 Correct 3 ms 384 KB Correct.
22 Correct 2 ms 428 KB Correct.
23 Correct 2 ms 384 KB Correct.
24 Correct 2 ms 384 KB Correct.
25 Correct 2 ms 384 KB Correct.
26 Correct 3 ms 384 KB Correct.
27 Correct 3 ms 384 KB Correct.