답안 #680107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680107 2023-01-09T22:55:14 Z GusterGoose27 GTA (COI14_gta) C++11
0 / 100
5000 ms 262144 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAXN = 100;
int TIME = 2e7;
string strings[MAXN];
int n;

set<string> vis;
bool adj[MAXN][MAXN];
vector<string> derived[2];
bool cur = 0;

map<char, string> conv;
map<string, string> conv2;

int it = 0;

void add_to(vector<string> &nxt, string s) {	
	for (int i = 0; i < s.size(); i++) {
		string nstr = s.substr(0, i)+conv[s[i]]+s.substr(i+1, s.size()-i-1);
		if (vis.find(nstr) == vis.end() && nstr.size()) {
			nxt.push_back(nstr);
			vis.insert(nstr);
		}
		it++;
	}
	for (int i = 0; i < s.size()-1; i++) {
		string seq = s.substr(i, 2);
		if (conv2.find(seq) != conv2.end()) {
			string nstr = s.substr(0, i)+conv2[seq]+s.substr(i+2, s.size()-i-2);
			if (vis.find(nstr) == vis.end() && nstr.size()) {
				nxt.push_back(nstr);
				vis.insert(nstr);
			}
		}
		it++;
	}
}

void makeable(int i) {
	vis.clear();
	derived[cur].clear();
	derived[cur].push_back(strings[i]);
	it = 0;
	while (it < 2*TIME/n) {
		derived[!cur].clear();
		for (string s: derived[cur]) {
			add_to(derived[!cur], s);
			if (it >= 2*TIME/n/n) break;
		}
		cur = !cur;
	}
	for (int j = 0; j < i; j++) adj[i][j] = adj[j][i] = (vis.find(strings[j]) != vis.end());
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	conv['A'] = "TC";
	conv['C'] = "AG";
	conv['G'] = "CT";
	conv['T'] = "GA";
	conv2["TC"] = "A";
	conv2["AG"] = "C";
	conv2["CT"] = "G";
	conv2["GA"] = "T";
	for (int i = 0; i < n; i++) {
		cin >> strings[i];
		adj[i][i] = 1;
	}
	for (int i = 1; i < n; i++) {
		makeable(i);
	}
}

Compilation message

gta.cpp: In function 'void add_to(std::vector<std::__cxx11::basic_string<char> >&, std::string)':
gta.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (int i = 0; i < s.size(); i++) {
      |                  ~~^~~~~~~~~~
gta.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for (int i = 0; i < s.size()-1; i++) {
      |                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1590 ms 262144 KB Execution killed with signal 9
2 Runtime error 1206 ms 262144 KB Execution killed with signal 9
3 Execution timed out 5057 ms 217744 KB Time limit exceeded
4 Execution timed out 5042 ms 106824 KB Time limit exceeded
5 Execution timed out 5057 ms 116220 KB Time limit exceeded
6 Execution timed out 5063 ms 106760 KB Time limit exceeded
7 Execution timed out 5059 ms 107140 KB Time limit exceeded
8 Runtime error 1381 ms 262144 KB Execution killed with signal 9
9 Runtime error 198 ms 262144 KB Execution killed with signal 9
10 Runtime error 133 ms 262144 KB Execution killed with signal 9