QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133595 | #5666. Repetitive Elements | wytang1010 | AC ✓ | 5ms | 3788kb | C++14 | 1.4kb | 2023-08-02 11:37:54 | 2023-08-02 11:37:57 |
Judging History
answer
/*
* author: weiyutang
*/
#include <bits/stdc++.h>
using namespace std;
/* ===== BEGIN USER CODE ===== */
#define ll long long
#define ld long double
#define f first
#define s second
const int MOD = 1e9 + 7;
const vector<vector<int>> dirs4 {{0,1}, {1,0}, {-1,0}, {0,-1}};
const vector<vector<int>> dirs8 {{0,1}, {1,0}, {-1,0}, {0,-1}, {-1,-1}, {-1,1}, {1,-1}, {1,1}};
void solve() {
string st;
cin >> st;
int n = st.size();
for (int l = n / 2; l > 0; l--) {
for (int i = 0; i + l - 1 < n; i++) {
for (int i2 = i + l; i2 + l - 1 < n; i2++) {
// check if every characters are the same
bool same = true;
for (int k = 0; k < l; k++) {
if (st[i+k] != st[i2+k]) {
same = false;
break;
}
}
if (same) {
for (int k = 0; k < l; k++) cout << st[i + k];
cout << endl;
return;
}
}
}
}
cout << "Not found" << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
srand(chrono::steady_clock::now().time_since_epoch().count());
int t = 1;
cin >> t;
while (t--) {
solve();
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3788kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 5ms
memory: 3788kb
input:
50 TTGACAACTTCAGGTTGGCACTCCTTCATTTGGATTTCGGAATAATAGTTTTCTGCTCTGCC ATCCTATTCGGGGATAGGAGAGATGGGTTGCCGCTATAAAAGCATTTGAACTCCATTTCACTCCGTTGGCTAGGGGTCGCACTG CCGTAATATAAAGACTCGGAATTCCAATAGCTGCTATTTGCGAGTATGTGACTGAAAACACACCTATAAATATTAGCTGCGTACAAGCTA ATGGCTGCATGCAGGGTCGACTAGACACACTTTGTCT TTGAGGATGTCGACGTGTCT...
output:
CTTCA CATTT TAGCTGC TGCA ACGTG GCGCCGG CTCTT AGTAT AGAG ACAG TAT TGAC CTTG CGTC TACTGG GCCGGT GAA CAGTA GCGT GGTT CCCT GAG TAGAC GGTGC GCAGT TGAG ATCAA CCACACA GAGTC ATGTA ATGGTA TATA TATGAA TTCC CATACG TACCA TTAG GGAATGT CAGG GCT AAG CTGT GGAT TCTTC AAAAC ATG GATAA TTA ACATAT CAAT
result:
ok 50 lines