提出 #1611565


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define fi first
#define sc second
#define pb push_back
#define INF 100000000
int n;
char s[100005];
vector<int>vec[26];
int main(){
	scanf("%s",s);
	scanf("%d",&n);
	int x = strlen(s);
	rep(i,x){
		vec[s[i]-'a'].pb(i);
	}
	rep(i,n){
		string str;cin>>str;
		int B=str[0]-'a';
		if(vec[B].empty()){
			cout<<-1<<endl; continue;
		}
			int beg = vec[B][0];
			{
				for(int i=1;i<str.size();i++){
					int x = upper_bound(vec[str[i]-'a'].begin(),vec[str[i]-'a'].end(),beg)-vec[str[i]-'a'].begin();
					if(x==vec[str[i]-'a'].size()){
						puts("-1"); goto bad;
					}
					beg = vec[str[i]-'a'][x];
				}
				int R = beg;
				for(int i=str.size()-2;i>=0;i--){
					int x = lower_bound(vec[str[i]-'a'].begin(),vec[str[i]-'a'].end(),beg)-vec[str[i]-'a'].begin();
					if(x==0){
						puts("-1"); goto bad;
					}
					beg = vec[str[i]-'a'][x-1];
				}
				printf("%d %d\n",beg+1,R+1);
			}
			bad:;

		
	}
}

提出情報

提出日時
問題 F - 極小部分列
ユーザ neandehir
言語 C++14 (GCC 5.4.1)
得点 1
コード長 1099 Byte
結果 AC
実行時間 217 ms
メモリ 1272 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
               ^
./Main.cpp:15:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^

ジャッジ結果

セット名 sample all
得点 / 配点 0 / 0 1 / 1
結果
AC × 1
AC × 20
セット名 テストケース
sample sample-01.txt
all sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, sample-01.txt
ケース名 結果 実行時間 メモリ
01-01.txt AC 32 ms 256 KiB
01-02.txt AC 33 ms 384 KiB
01-03.txt AC 16 ms 1020 KiB
01-04.txt AC 15 ms 1020 KiB
01-05.txt AC 217 ms 1272 KiB
01-06.txt AC 16 ms 912 KiB
01-07.txt AC 16 ms 1012 KiB
01-08.txt AC 16 ms 1024 KiB
01-09.txt AC 34 ms 896 KiB
01-10.txt AC 116 ms 1152 KiB
01-11.txt AC 16 ms 896 KiB
01-12.txt AC 14 ms 896 KiB
01-13.txt AC 15 ms 768 KiB
01-14.txt AC 15 ms 768 KiB
01-15.txt AC 15 ms 892 KiB
01-16.txt AC 15 ms 768 KiB
01-17.txt AC 16 ms 896 KiB
01-18.txt AC 116 ms 1272 KiB
sample-01.txt AC 1 ms 256 KiB