Submission #70866637


Source Code Expand

#include <bits/stdc++.h>
using namespace std;


void rotate(bitset<1000000> &bits, int size){
  // bits[size] = 
  // bits[size-1]=0;
  bits<<=1;
  bits[0]=bits[size];
  bits[size]=0;
  // bits[0]=bits[size-1];
  // bits[0]=bit;/**/
}

void solve(){
  string a,b;
  cin >> a >> b;
  bitset<1000000> ba(a);
  bitset<1000000> bb(b);
  int s = a.size();
  for(int i=0; i<s; i++){
    // cout << ba << "\n";
    if(ba==bb){
      cout << i<<"\n";
      return;
    }
    rotate(ba, s);
  }
  
  // bitset<40> test = 1;
  // for(int i=0; i<40; i++){
  //   cout << test << "\n";
  //   rotate(test, 40);
  // }
  
  cout << "-1\n";
}

int main() 
{
    int tc;
    cin >> tc;
    while(tc--){
      solve();
    }
    return 0;
}

Submission Info

Submission Time
Task A - Candy Cookie Law
User ashfn
Language C++23 (GCC 15.2.0)
Score 0
Code Size 770 Byte
Status RE
Exec Time 96 ms
Memory 4128 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
WA × 1
RE × 2
WA × 1
RE × 11
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt RE 95 ms 3712 KiB
random_02.txt RE 95 ms 3788 KiB
random_03.txt RE 94 ms 3816 KiB
random_04.txt RE 95 ms 3860 KiB
random_05.txt RE 94 ms 4128 KiB
random_06.txt RE 95 ms 3776 KiB
random_07.txt RE 94 ms 3824 KiB
random_08.txt RE 95 ms 3904 KiB
random_09.txt RE 94 ms 3776 KiB
sample_01.txt RE 94 ms 4128 KiB
sample_02.txt RE 96 ms 3836 KiB
sample_03.txt WA 2 ms 3840 KiB