AtCoder Beginner Contest 030

Submission #1675409

Source codeソースコード

#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include<cstdint>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];
 
ll par[100000], depth[100000];
static void calc_comb()
{
    for (uint32_t i = 0; i <= MAX_NUM; i++) {
        for (uint32_t j = 0; j <= i; j++) {
            if ((j == 0) || (i == j)) {
                comb[i][j] = 1;
            }
            else {
                comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
            }
        }
    }
}
#define yo 100001
typedef pair<ll, double> dop;
 
//------------------変数-----------------------//
ll n,m,t,a,beet[114514];
string k;
vector<ll> izryt;
//-------------------関数----------------------//
 
ll MMMOD (string dividend, ll divisor) {
    ll MOD = 0, N = dividend.size();
    for (int i = 0; i < N; ++i) {
        MOD = (MOD * 10 + (dividend[i] - '0')) % divisor;
    }
    return MOD;
}
 
int main(){
    cin>>n;
    cin>>a;
    cin>>k;
    REP(i,n){
        cin>>beet[i];beet[i]--;
    }
    bool hoge[114514]={};
    ll now=beet[a-1];
    ll start;
    while(1){
 ///       cout<<now<<"a"<<endl;
        if(hoge[now]){
            REP(i,izryt.size()){
                if(izryt[i]==now){
                    start=i;
                }
            }
            break;
        }
        hoge[now]=true;
    
        izryt.push_back(now);
        now=beet[now];
    }
    if(k.size()<10){
        if(stoi(k)-1<start){
            cout<<izryt[stoi(k)-1]+1<<endl;return 0;
        }
    }
    REP(i,izryt.size()){
 /// cout<<izryt[i]<<"aaa"<<endl;
    }
  ///  cout<<start<<endl;
    ll kei=MMMOD(k,izryt.size()-start);
kei-=start+1;
kei%=izryt.size()-start;
 ///cout<<kei<<endl;
if(kei<0){kei=-kei;}
   ///cout<<kei<<endl;
   
    cout<<izryt[kei+start]+1<<endl;
    
    return 0;
}

Submission

Task問題 D - へんてこ辞書
User nameユーザ名 keidaroo
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 2692 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample_01.txt,subtask0_sample_03.txt
Subtask1 0 / 50 subtask0_0.txt,subtask0_1.txt,subtask0_2.txt,subtask0_3.txt,subtask0_4.txt,subtask0_5.txt,subtask0_6.txt,subtask0_7.txt,subtask0_8.txt,subtask0_9.txt,subtask0_sample_01.txt,subtask0_sample_03.txt
All 0 / 50 subtask0_0.txt,subtask0_1.txt,subtask0_2.txt,subtask0_3.txt,subtask0_4.txt,subtask0_5.txt,subtask0_6.txt,subtask0_7.txt,subtask0_8.txt,subtask0_9.txt,subtask0_sample_01.txt,subtask0_sample_03.txt,subtask1_0.txt,subtask1_1.txt,subtask1_10.txt,subtask1_11.txt,subtask1_2.txt,subtask1_3.txt,subtask1_4.txt,subtask1_5.txt,subtask1_6.txt,subtask1_7.txt,subtask1_8.txt,subtask1_9.txt,subtask1_sample_02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_0.txt WA
subtask0_1.txt AC 21 ms 896 KB
subtask0_2.txt WA
subtask0_3.txt WA
subtask0_4.txt WA
subtask0_5.txt WA
subtask0_6.txt WA
subtask0_7.txt WA
subtask0_8.txt WA
subtask0_9.txt AC 25 ms 1024 KB
subtask0_sample_01.txt AC 1 ms 384 KB
subtask0_sample_03.txt AC 1 ms 384 KB
subtask1_0.txt AC 22 ms 1024 KB
subtask1_1.txt WA
subtask1_10.txt WA
subtask1_11.txt WA
subtask1_2.txt WA
subtask1_3.txt WA
subtask1_4.txt WA
subtask1_5.txt WA
subtask1_6.txt WA
subtask1_7.txt AC 19 ms 1024 KB
subtask1_8.txt WA
subtask1_9.txt AC 30 ms 1280 KB
subtask1_sample_02.txt AC 1 ms 384 KB