Submission #75649467


Source Code Expand

//競プロ C++テンプレ
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(),x.end()
#define ll long long
#define pb push_back

ll gcd(ll a, ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b, a%b);
  }
}

int main() {
    ll N,K;
    cin >> N >> K;
    
    vector<ll> ret(N);
    vector<vector<ll>> vec(N);
    vector<ll> cc(N);
    for(int i = 0; i < N;i++){
      cin >> ret.at(i);
      for(int j = 0; j < ret.at(i); j++){
        ll jut;
        cin >> jut;
        vec.at(i).push_back(jut);
      }
    }
    
    for(int j = 0; j < N; j++){
        ll jut;
        cin >> jut;
        cc.at(j) = ret.at(j) * jut;
    }
    
    ll chack = 0;
    ll ans;
    K -= 1;
    while(K >0){
      if(K > cc.at(chack)){
        K -= cc.at(chack);
        chack++;
      }else if(K == cc.at(chack)){
        ll aa = vec.at(chack+1).at(0);
        cout << aa;
        return 0;
      }else{
        ans = K % ret.at(chack);
        break;
      }
    }
    
    //cout << chack << ans;
    ll aa = vec.at(chack).at(ans);
    cout << aa;
}

Submission Info

Submission Time
Task C - Long Sequence
User gumi11ta
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1132 Byte
Status AC
Exec Time 136 ms
Memory 17304 KiB

Compile Error

./Main.cpp: In function 'main':
./Main.cpp:57:29: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   57 |     ll aa = vec.at(chack).at(ans);
      |                             ^
./Main.cpp:40:8: note: 'ans' was declared here
   40 |     ll ans;
      |        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 23
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3520 KiB
00_sample_01.txt AC 1 ms 3532 KiB
00_sample_02.txt AC 1 ms 3520 KiB
01_random_00.txt AC 76 ms 7560 KiB
01_random_01.txt AC 102 ms 11172 KiB
01_random_02.txt AC 68 ms 6524 KiB
01_random_03.txt AC 95 ms 10200 KiB
01_random_04.txt AC 96 ms 10412 KiB
01_random_05.txt AC 87 ms 9204 KiB
01_random_06.txt AC 72 ms 7156 KiB
01_random_07.txt AC 135 ms 16932 KiB
01_random_08.txt AC 59 ms 6100 KiB
01_random_09.txt AC 116 ms 13776 KiB
01_random_10.txt AC 56 ms 5576 KiB
01_random_11.txt AC 56 ms 5556 KiB
01_random_12.txt AC 56 ms 5496 KiB
01_random_13.txt AC 136 ms 17300 KiB
01_random_14.txt AC 136 ms 17256 KiB
01_random_15.txt AC 135 ms 17304 KiB
01_random_16.txt AC 119 ms 14076 KiB
01_random_17.txt AC 102 ms 11216 KiB
01_random_18.txt AC 93 ms 9916 KiB
01_random_19.txt AC 58 ms 5828 KiB