buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main() {
int dataSetNum;
std::cin >> dataSetNum;
std::vector<std::string> str;
str.resize(dataSetNum);
std::cin.ignore();
// input
for (int i = 0; i < dataSetNum; ++i) {
// input
std::string tmp;
getline(std::cin, tmp);
str[i] = tmp;
}
// replace
for (int i = 0; i < dataSetNum; ++i) {
const std::string tmp("Hoshino");
auto pos = str[i].find(tmp);
while (pos != std::string::npos) {
str[i].replace(pos, 7, "Hoshima");
pos = str[i].find(tmp, pos + 7);
}
}
// output
std::for_each(str.begin(), str.end(),
[](std::string x) { std::cout << x << std::endl; });
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main() {
int dataSetNum;
std::cin >> dataSetNum;
std::vector<std::string> str;
str.resize(dataSetNum);
std::cin.ignore();
// input
for (int i = 0; i < dataSetNum; ++i) {
// input
std::string tmp;
getline(std::cin, tmp);
str[i] = tmp;
}
// replace
for (int i = 0; i < dataSetNum; ++i) {
const std::string tmp("Hoshino");
auto pos = str[i].find(tmp);
while (pos != std::string::npos) {
str[i].replace(pos, 7, "Hoshina");
pos = str[i].find(tmp, pos + 7);
}
}
// output
std::for_each(str.begin(), str.end(),
[](std::string x) { std::cout << x << std::endl; });
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 214
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
string s;
getline(cin, s);
for (int i = 6; i < s.length(); i++)
if (s[i] == 'o' && s[i - 1] == 'n' && s[i - 2] == 'i' &&
s[i - 3] == 'h' && s[i - 4] == 's' && s[i - 5] == 'o' &&
s[i - 6] == 'H')
s[i] = 'a', s[i - 1] = 'n', s[i - 2] = 'i', s[i - 3] = 'h',
s[i - 4] = 's', s[i - 5] = 'o', s[i - 6] = 'H';
cout << s << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
cin.ignore();
while (n--) {
string s;
getline(cin, s);
for (int i = 6; i < s.length(); i++)
if (s[i] == 'o' && s[i - 1] == 'n' && s[i - 2] == 'i' &&
s[i - 3] == 'h' && s[i - 4] == 's' && s[i - 5] == 'o' &&
s[i - 6] == 'H')
s[i] = 'a', s[i - 1] = 'n', s[i - 2] = 'i', s[i - 3] = 'h',
s[i - 4] = 's', s[i - 5] = 'o', s[i - 6] = 'H';
cout << s << endl;
}
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
| 1
| 214
| 6
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int n;
cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
getline(cin, s);
while (s.find("Hoshino") != string::npos) {
s.replace(s.find("Hoshino"), 7, "Hashino");
}
cout << s << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int n;
cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
getline(cin, s);
while (s.find("Hoshino") != string::npos) {
s.replace(s.find("Hoshino"), 7, "Hoshina");
}
cout << s << endl;
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 94
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, i = 0;
string s;
cin >> n;
for (; i < n; i++) {
getline(cin, s);
while (s.find("Hoshino") != string::npos)
s.replace(s.find("Hoshino"), 7, "Hoshina");
cout << s << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, i = 0;
string s;
cin >> n;
cin.ignore();
for (; i < n; i++) {
getline(cin, s);
while (s.find("Hoshino") != string::npos)
s.replace(s.find("Hoshino"), 7, "Hoshina");
cout << s << endl;
}
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
| 1
| 88
| 6
|
#include <iostream>
#include <string>
int main() {
std::string str;
int num;
int start = 0;
std::cin >> num;
getline(std::cin, str); // skip "\n"
for (int i = 0; i < num; ++i) {
std::getline(std::cin, str);
while (start != -1) {
if (start == 0) { // for first loop
start = (int)str.find("Hoshino", start);
} else {
start = (int)str.find("Hoshino", start + 8);
}
if (start != -1) { // for first loop
str.replace(start, start + 7, "Hoshina");
}
}
std::cout << str << std::endl;
start = 0;
}
}
|
#include <iostream>
#include <string>
int main() {
std::string str;
int num;
int start = 0;
std::cin >> num;
getline(std::cin, str); // skip "\n"
for (int i = 0; i < num; ++i) {
std::getline(std::cin, str);
while (start != -1) {
if (start == 0) { // for first loop
start = (int)str.find("Hoshino", start);
} else {
start = (int)str.find("Hoshino", start + 7);
}
if (start != -1) { // for first loop
str.replace(start, 7, "Hoshina");
}
}
std::cout << str << std::endl;
start = 0;
}
}
|
[["-", 12, 74, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 12, 74, 51, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72]]
| 1
| 158
| 4
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
int n;
cin >> n;
cin.ignore();
while (n--) {
getline(cin, str);
for (int j = 0; j < (int)str.size() - 7; j++) {
string key = str.substr(j, 7), repl;
if (key == "Hoshino") {
repl = "Hoshina";
for (int k = 0; k < n; k++) {
str[j + k] = repl[k];
}
}
}
cout << str << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
int n;
cin >> n;
cin.ignore();
while (n--) {
getline(cin, str);
for (int j = 0; j < (int)str.size(); j++) {
string key = str.substr(j, 7), repl;
if (key == "Hoshino") {
repl = "Hoshina";
for (int k = 0; k < 7; k++) {
str[j + k] = repl[k];
}
}
}
cout << str << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 134
| 4
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
getline(cin, str);
while (string::npos != str.find("Hoshino")) {
int pnt = str.find("Hoshino");
str.replace(pnt, 7, "Hoshina");
}
cout << str << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int n;
cin >> n;
cin.ignore();
for (int i = 0; i < n; ++i) {
getline(cin, str);
while (string::npos != str.find("Hoshino")) {
int pnt = str.find("Hoshino");
str.replace(pnt, 7, "Hoshina");
}
cout << str << endl;
}
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
| 1
| 95
| 6
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
ios::sync_with_stdio(false);
string str1, str2, str3;
str2 = "Hosino";
str3 = "Hosina";
int n;
cin >> n;
cin.ignore();
while (n--) {
getline(cin, str1);
string::size_type pos = str1.find(str2);
while (pos != string::npos) {
str1.replace(pos, str2.size(), str3);
pos = str1.find(str2, pos + str3.size());
}
cout << str1 << endl;
}
}
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
ios::sync_with_stdio(false);
string str1, str2, str3;
str2 = "Hoshino";
str3 = "Hoshina";
int n;
cin >> n;
cin.ignore();
while (n--) {
getline(cin, str1);
string::size_type pos = str1.find(str2);
while (pos != string::npos) {
str1.replace(pos, str2.size(), str3);
pos = str1.find(str2, pos + str3.size());
}
cout << str1 << endl;
}
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6]]
| 1
| 301
| 4
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
scanf("%d ", &n);
while (n--) {
string s;
for (getline(cin, s), i = 0; i < s.size(); i++) {
if (s[i] == 'H')
if (s[i + 1] == 'o')
if (s[i + 2] == 's')
if (s[i + 3] == 'h')
if (s[i + 4] == 'i')
if (s[i + 5] == 'n')
if (s[i + 6] == 'a')
s[i + 6] = 'o';
}
cout << s << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
scanf("%d ", &n);
while (n--) {
string s;
for (getline(cin, s), i = 0; i < s.size(); i++) {
if (s[i] == 'H')
if (s[i + 1] == 'o')
if (s[i + 2] == 's')
if (s[i + 3] == 'h')
if (s[i + 4] == 'i')
if (s[i + 5] == 'n')
if (s[i + 6] == 'o')
s[i + 6] = 'a';
}
cout << s << endl;
}
}
|
[["-", 64, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 64, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["-", 64, 57, 64, 1, 0, 11, 12, 103, 0, 125], ["+", 64, 57, 64, 1, 0, 11, 12, 103, 0, 125]]
| 1
| 169
| 4
|
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define pi 3.14159265358979323846264338
using namespace std;
int main() {
int n;
cin >> n;
string sub;
for (int i = 0; i < n; ++i) {
string s;
getline(cin, s);
for (int j = 0; j < s.size(); ++j) {
if (s.size() < 7) {
break;
}
sub = s.substr(j, 7);
if (sub == "Hoshino") {
s.replace(j, 7, "Hoshina");
}
}
cout << s << endl;
}
return 0;
}
|
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define pi 3.14159265358979323846264338
using namespace std;
int main() {
int n;
cin >> n;
string sub;
getchar();
for (int i = 0; i < n; ++i) {
string s;
getline(cin, s);
for (int j = 0; j < s.size(); ++j) {
if (s.size() < 7) {
break;
}
sub = s.substr(j, 7);
if (sub == "Hoshino") {
s.replace(j, 7, "Hoshina");
}
}
cout << s << endl;
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
| 1
| 140
| 4
|
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
string s;
getline(cin, s);
while (s.find("Hoshino") != string::npos) {
s.replace(s.find("Hoshino"), 7, "Hoshina");
}
cout << s << endl;
}
// while(1);
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
getchar();
while (n--) {
string s;
getline(cin, s);
while (s.find("Hoshino") != string::npos) {
s.replace(s.find("Hoshino"), 7, "Hoshina");
}
cout << s << endl;
}
// while(1);
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
| 1
| 109
| 4
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string s;
int n;
cin >> n;
getline(cin, s);
for (int j = 0; j < n; j++) {
getline(cin, s);
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
s[i + 6] == 'o') {
cout << "Hoshina";
i += 7;
} else
cout << s[i];
}
cout << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string s;
int n;
cin >> n;
getline(cin, s);
for (int j = 0; j < n; j++) {
getline(cin, s);
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
s[i + 6] == 'o') {
cout << "Hoshina";
i += 6;
} else
cout << s[i];
}
cout << endl;
}
return 0;
}
|
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
| 1
| 182
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int n;
cin >> n;
getline(cin, str);
for (int i = 0; i < n; i++) {
getline(cin, str);
for (int j = 0; j < int(str.size()) - 6; j++) {
if (str.substr(j, 6) == "Hoshino")
str.replace(j, 7, "Hoshina");
}
cout << str << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
int n;
cin >> n;
getline(cin, str);
for (int i = 0; i < n; i++) {
getline(cin, str);
for (int j = 0; j < int(str.size()) - 6; j++) {
if (str.substr(j, 7) == "Hoshino")
str.replace(j, 7, "Hoshina");
}
cout << str << endl;
}
}
|
[["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 13], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 13]]
| 1
| 113
| 2
|
#include <stdio.h>
int main() {
int n, i, j = 0, k;
char alph, str[1008], temp;
scanf("%d", &n);
temp = getchar();
for (i = 0; i < n; i++) {
for (j = 0;; j++) {
str[j] = getchar();
if (str[j] == '\n') {
str[j] = '\0';
break;
}
}
for (k = 0; k < j; k++) {
if (str[k] == 'A' && str[k + 1] == 'o' && str[k + 2] == 's' &&
str[k + 3] == 'h' && str[k + 4] == 'i' && str[k + 5] == 'n' &&
str[k + 6] == 'o') {
str[k + 6] = 'a';
}
}
printf("%s\n", str);
}
return 0;
}
|
#include <stdio.h>
int main() {
int n, i, j = 0, k;
char str[1008], temp;
scanf("%d", &n);
temp = getchar();
for (i = 0; i < n; i++) {
for (j = 0;; j++) {
str[j] = getchar();
if (str[j] == '\n') {
str[j] = '\0';
break;
}
}
for (k = 0; k < j; k++) {
if (str[k] == 'H' && str[k + 1] == 'o' && str[k + 2] == 's' &&
str[k + 3] == 'h' && str[k + 4] == 'i' && str[k + 5] == 'n' &&
str[k + 6] == 'o')
str[k + 6] = 'a';
}
printf("%s\n", str);
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 31, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 31, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
| 1
| 223
| 6
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
scanf("%d ", &n);
string a[n];
for (int i = 0; i < n; i++) {
getline(cin, a[i]);
while (1) {
int index;
index = a[i].find("Hoshino", index);
if ((int)string::npos == index)
break;
a[i][index + 6] = 'a';
}
}
for (int i = 0; i < n; i++) {
cout << a[i] << "\n";
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
scanf("%d ", &n);
string a[n];
for (int i = 0; i < n; i++) {
getline(cin, a[i]);
while (1) {
int index = 0;
index = a[i].find("Hoshino", index);
if ((int)string::npos == index)
break;
a[i][index + 6] = 'a';
}
}
for (int i = 0; i < n; i++) {
cout << a[i] << "\n";
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
| 1
| 143
| 2
|
#include <iostream>
#include <string>
int main() {
std::string s;
int n;
std::cin >> n, std::cin.get();
for (; n; n--) {
getline(std::cin, s);
int pos = 0;
while (pos = s.find("Hoshino", pos), pos != std::string::npos) {
s.replace(pos, 7, "Hashino");
pos += 7;
}
std::cout << s << std::endl;
}
return 0;
}
|
#include <iostream>
#include <string>
int main() {
std::string s;
int n;
std::cin >> n, std::cin.get();
for (; n; n--) {
getline(std::cin, s);
int pos = 0;
while (pos = s.find("Hoshino", pos), pos != std::string::npos) {
s.replace(pos, 7, "Hoshina");
pos += 7;
}
std::cout << s << std::endl;
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 111
| 2
|
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int n, i, j, k, c, x;
char s[1001], r[1001], t[8] = "Hoshino";
cin >> n;
cin.ignore('\n');
for (i = 0; i < n; i++) {
cin.getline(s, sizeof(s));
c = 0;
for (j = 0; j < strlen(s); j++) {
r[c] = s[j];
c++;
if (s[j] == 'H') {
for (k = j + 1, x = 0; k < j + 7; k++, c++) {
if (s[k] == t[k - j]) {
if (k == j + 6)
r[c] = 'a';
else
r[c] = t[k - j];
x++;
} else {
r[c] = s[k];
break;
}
}
j += x;
}
}
r[strlen(s)] = '\0';
cout << r << endl;
}
}
|
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int n, i, j, k, c, x;
char s[1001], r[1001], t[8] = "Hoshino";
cin >> n;
cin.ignore(1024, '\n');
for (i = 0; i < n; i++) {
cin.getline(s, sizeof(s));
c = 0;
for (j = 0; j < strlen(s); j++) {
r[c] = s[j];
c++;
if (s[j] == 'H') {
for (k = j + 1, x = 0; k < j + 7; k++, c++) {
if (s[k] == t[k - j]) {
if (k == j + 6)
r[c] = 'a';
else
r[c] = t[k - j];
x++;
} else {
r[c] = s[k];
break;
}
}
j += x;
}
}
r[strlen(s)] = '\0';
cout << r << endl;
}
}
|
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21]]
| 1
| 247
| 2
|
#include <stdio.h>
int main() {
int n, a[5000], m, p, q;
bool b[5000], f;
while (1) {
scanf("%d", &n);
if (n == 0)
return 0;
for (int i = 0; i < 5000; i++)
a[i] = b[i] = 0;
f = false;
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &m, &p, &q);
if (!b[m]) {
a[m] += p * q;
if (a[m] > 1000000) {
b[m] = true;
f = true;
printf("%d\n", m);
}
}
}
if (!f)
printf("NA\n");
}
}
|
#include <stdio.h>
int main() {
int n, a[5000], m, p, q;
bool b[5000], f;
while (1) {
scanf("%d", &n);
if (n == 0)
return 0;
for (int i = 0; i < 5000; i++)
a[i] = b[i] = 0;
f = false;
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &m, &p, &q);
if (!b[m]) {
a[m] += p * q;
if (a[m] >= 1000000) {
b[m] = true;
f = true;
printf("%d\n", m);
}
}
}
if (!f)
printf("NA\n");
}
}
|
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
| 1
| 181
| 2
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
int main(void) {
for (int j = 0; j < 50; j++) {
cout << endl;
long n, e[4000], x[4000], y[4000], co[100];
cin >> n;
if (n == 0) {
break;
}
for (int i = 0; i < n; i++) {
cin >> e[i] >> x[i] >> y[i];
}
for (int i = 0; i < n; i++) {
co[i] = 0;
for (int k = 0; k < n; k++) {
if (i <= k && e[i] == e[k]) {
co[i] += x[k] * y[k];
if (i != k) {
e[k] = -1;
}
}
}
}
int gg = 0;
for (int i = 0; i < n; i++) {
if (e[i] != -1 && co[i] >= 1000000) {
gg += -1;
cout << e[i] << endl;
}
if (i == n - 1 && gg == 0) {
cout << "NA" << endl;
}
}
}
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
int main(void) {
for (int j = 0; j < 50; j++) {
long n, e[4000], x[4000], y[4000], co[4000];
cin >> n;
if (n == 0) {
break;
}
for (int i = 0; i < n; i++) {
cin >> e[i] >> x[i] >> y[i];
}
for (int i = 0; i < n; i++) {
co[i] = 0;
for (int k = 0; k < n; k++) {
if (i <= k && e[i] == e[k]) {
co[i] += x[k] * y[k];
if (i != k) {
e[k] = -1;
}
}
}
}
int gg = 0;
for (int i = 0; i < n; i++) {
if (e[i] != -1 && co[i] >= 1000000) {
gg += -1;
cout << e[i] << endl;
}
if (i == n - 1 && gg == 0) {
cout << "NA" << endl;
}
}
}
}
|
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["-", 0, 7, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 80, 81, 13]]
| 1
| 280
| 6
|
#include <iostream>
using namespace std;
int main() {
long long data[2][4000], n, i, f, id, a, b;
while (1) {
cin >> n;
if (n == 0)
break;
for (i = 0; i < 4000; i++)
data[0][i] = -1, data[1][i] = 0;
for (i = 0; i < n; i++) {
cin >> id >> a >> b;
for (f = 0; f < i + 1; f++) {
if (data[0][f] == id) {
(a * b >= 1000000) ? (data[1][f] += (a * b)) : (data[1][f] = 1000000);
break;
} else if (data[0][f] == -1) {
data[0][f] = id;
(a * b >= 1000000) ? (data[1][f] = (a * b)) : (data[1][f] = 1000000);
break;
}
}
}
for (i = 0, f = 0; i < n; i++) {
if (data[1][i] >= 1000000)
cout << data[0][i] << "\n", f = 1;
if (data[0][i] == -1)
break;
// cout<<"id : "<<data[0][i]<<" sale: "<<data[1][i]<<endl;
}
if (f == 0)
cout << "NA" << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
long long data[2][4000], n, i, f, id, a, b;
while (1) {
cin >> n;
if (n == 0)
break;
for (i = 0; i < 4000; i++)
data[0][i] = -1, data[1][i] = 0;
for (i = 0; i < n; i++) {
cin >> id >> a >> b;
for (f = 0; f < i + 1; f++) {
if (data[0][f] == id) {
(a * b < 1000000) ? (data[1][f] += (a * b)) : (data[1][f] = 1000000);
break;
} else if (data[0][f] == -1) {
data[0][f] = id;
(a * b < 1000000) ? (data[1][f] = (a * b)) : (data[1][f] = 1000000);
break;
}
}
}
for (i = 0, f = 0; i < n; i++) {
if (data[1][i] >= 1000000)
cout << data[0][i] << "\n", f = 1;
if (data[0][i] == -1)
break;
// cout<<"id : "<<data[0][i]<<" sale: "<<data[1][i]<<endl;
}
if (f == 0)
cout << "NA" << endl;
}
}
|
[["-", 0, 1, 0, 41, 15, 23, 0, 16, 17, 20], ["+", 0, 1, 0, 41, 15, 23, 0, 16, 17, 18]]
| 1
| 318
| 4
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
int ans[4000];
for (;;) {
cin >> n;
if (n == 0)
break;
int i, j;
for (i = 0, j = 0; i < n; i++) {
int num[4000];
int flag = 1;
double a[4000], b[4000];
double ans_max[4000];
cin >> num[i] >> a[i] >> b[i];
ans_max[i] = a[i] / 10000.0 * b[i];
for (int l = i; l >= 0; l++) {
if (num[l] == num[i]) {
// cout << "in" << endl;
ans_max[i] += ans_max[l];
break;
}
}
if (ans_max[i] >= 100.0) {
for (int k = 0; k < j; k++) {
if (ans[k] == num[i])
flag = 0;
}
if (flag == 1) {
ans[j] = num[i];
j++;
}
}
}
if (j != 0) {
for (int i = 0; i < j; i++) {
cout << ans[i] << endl;
}
} else
cout << "NA" << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
int ans[4000];
for (;;) {
cin >> n;
if (n == 0)
break;
int i, j;
for (i = 0, j = 0; i < n; i++) {
int num[4000];
int flag = 1;
double a[4000], b[4000];
double ans_max[4000];
cin >> num[i] >> a[i] >> b[i];
ans_max[i] = a[i] / 10000.0 * b[i];
for (int l = i - 1; l >= 0; l--) {
if (num[l] == num[i]) {
// cout << "in" << endl;
ans_max[i] += ans_max[l];
break;
}
}
// cout << "ans_max[" << i << "]:" << ans_max[i] <<
//" num:" << num[i] << endl;
if (ans_max[i] >= 100.0) {
for (int k = 0; k < j; k++) {
if (ans[k] == num[i])
flag = 0;
}
if (flag == 1) {
ans[j] = num[i];
j++;
}
}
}
if (j != 0) {
for (int i = 0; i < j; i++) {
cout << ans[i] << endl;
}
} else
cout << "NA" << endl;
}
}
|
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 17, 68]]
| 1
| 277
| 4
|
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define ll long long
bool debug = true;
int main(void) {
map<int, ll> m;
vector<int> order;
int n;
int no, amount, price;
while (cin >> n) {
bool exist = false;
if (!n)
break;
for (int i = 0; i < n; i++) {
cin >> no >> amount >> price;
if (find(order.begin(), order.end(), no) == order.end()) {
order.push_back(no);
if (debug)
cout << "pushed " << no << endl;
}
m[no] += (ll)amount * price;
}
for (int i = 0; i < order.size(); i++) {
if (m[order[i]] >= 1e+6) {
cout << order[i] << endl;
exist = true;
}
}
if (!exist)
cout << "NA" << endl;
m.clear();
order.clear();
}
}
|
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define ll long long
bool debug = false;
int main(void) {
map<int, ll> m;
vector<int> order;
int n;
long long no, amount, price;
while (cin >> n) {
bool exist = false;
if (!n)
break;
for (int i = 0; i < n; i++) {
cin >> no >> amount >> price;
if (find(order.begin(), order.end(), no) == order.end()) {
order.push_back(no);
if (debug)
cout << "pushed " << no << endl;
}
m[no] += (ll)amount * price;
}
for (int i = 0; i < order.size(); i++) {
if (m[order[i]] >= 1e+6) {
cout << order[i] << endl;
exist = true;
}
}
if (!exist)
cout << "NA" << endl;
m.clear();
order.clear();
}
}
|
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 146], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 147], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 227
| 5
|
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
int n, f;
// mlÛ¶vÛ¶
long long int a, b, c;
// aÔbP¿cÊ
while (cin >> n, n) {
map<int, long long> m;
vector<int> v;
f = 1;
for (; n; n--) {
std::cin >> a >> b >> c;
if (m[a])
v.push_back(a);
m[a] += b * c;
}
for (int i = 0; i < v.size(); i++) {
if (m[v[i]] > 999999) {
f = 0;
cout << v[i] << endl;
}
}
if (f)
cout << "NA" << endl;
}
return 0;
}
|
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
int n, f;
// mlÛ¶vÛ¶
long long a, b, c;
// aÔbP¿cÊ
while (cin >> n, n) {
map<int, long long> m;
vector<int> v;
f = 1;
for (; n; n--) {
std::cin >> a >> b >> c;
if (!m[a])
v.push_back(a);
m[a] += b * c;
}
for (int i = 0; i < v.size(); i++) {
if (m[v[i]] > 999999) {
f = 0;
cout << v[i] << endl;
}
}
if (f)
cout << "NA" << endl;
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 39, 40], ["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111]]
| 1
| 166
| 23
|
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) && n != 0) {
map<int, long long> sales;
vector<int> log;
long long int prc, mnt;
int num;
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &num, &prc, &mnt);
if (!sales[num]) {
log.push_back(num);
}
sales[num] += prc * mnt;
}
bool flag = true;
for (int i = 0; i < log.size(); i++) {
if (sales[log[i]] >= 1000000) {
flag = false;
printf("%d\n", log[i]);
}
}
if (flag)
printf("NA\n");
}
}
|
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) && n != 0) {
map<int, long long> sales;
vector<int> log;
long long prc, mnt;
int num;
for (int i = 0; i < n; i++) {
scanf("%d%lld%lld", &num, &prc, &mnt);
if (!sales[num]) {
log.push_back(num);
}
sales[num] += prc * mnt;
}
bool flag = true;
for (int i = 0; i < log.size(); i++) {
if (sales[log[i]] >= 1000000) {
flag = false;
printf("%d\n", log[i]);
}
}
if (flag)
printf("NA\n");
}
}
|
[["-", 0, 52, 8, 9, 0, 43, 39, 86, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 190
| 3
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ITER(T) __typeof((T).begin())
#define each(T, it) for (ITER(T) it = (T).begin(); it != (T).end(); it++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
const int INF = 1 << 24;
const int N = 4001;
const int B = (int)1e6;
int main(void) {
for (int n, f; cin >> n, n; cout << (f ? "" : "NA\n")) {
vector<ll> in(N);
vi p;
while (f = n--) {
int id;
ll v, m;
cin >> id >> v >> m;
if ((in[id] += (ll)v * m) >= B)
in[id] = B;
if (find(ALL(p), id) == p.end())
p.pb(id);
}
each(p, it) if (f = in[*it] == B) cout << *it << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ITER(T) __typeof((T).begin())
#define each(T, it) for (ITER(T) it = (T).begin(); it != (T).end(); it++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
const int INF = 1 << 24;
const int N = 4001;
const int B = (int)1e6;
int main(void) {
for (int n, f; cin >> n, n; cout << (f ? "" : "NA\n")) {
vector<ll> in(N);
vi p;
while (f = n--) {
int id;
ll v, m;
cin >> id >> v >> m;
if ((in[id] += (ll)v * m) >= B)
in[id] = B;
if (find(ALL(p), id) == p.end())
p.pb(id);
}
each(p, it) if (in[*it] == B) cout << *it << endl, f = 1;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 17, 32], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 12, 13]]
| 1
| 274
| 6
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
static const double PI = 6 * asin(0.5);
typedef complex<double> P;
typedef long long ll;
ll n;
int main() {
while (cin >> n, n != 0) {
ll id[4005] = {0};
int a[8000] = {0};
int cou;
rep(i, n) {
ll t1, t2, t3;
cin >> t1 >> t2 >> t3;
a[i] = t1;
// if(id[t1]>0){
id[t1] += t2 * t3;
//}
/*
else{
id[t1]=t2*t3;
}
*/
cou = i;
}
bool f = true;
rep(i, cou) {
if (id[a[i]] >= 1000000) {
cout << a[i] << endl;
id[a[i]] = 0;
f = false;
}
}
if (f)
cout << "NA" << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
static const double PI = 6 * asin(0.5);
typedef complex<double> P;
typedef long long ll;
ll n;
int main() {
while (cin >> n, n != 0) {
ll id[4005] = {0};
int a[8000] = {0};
int cou;
rep(i, n) {
ll t1, t2, t3;
cin >> t1 >> t2 >> t3;
a[i] = t1;
// if(id[t1]>0){
id[t1] += t2 * t3;
//}
/*
else{
id[t1]=t2*t3;
}
*/
cou = i;
}
bool f = true;
rep(i, cou + 1) {
if (id[a[i]] >= 1000000) {
cout << a[i] << endl;
id[a[i]] = 0;
f = false;
}
}
if (f)
cout << "NA" << endl;
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
| 1
| 213
| 3
|
while true
hash = Hash.new
n = gets.to_i #???????????°
break if n == 0
for r in 0...n do
line = gets.chomp!
line = line.split
no = line[0].to_i #????????????
unitPrice = line[1].to_i #????£???????
quantity = line[2].to_i #?£??????°???
total = unitPrice * quantity #?°??¨?
if hash.key?(no)
total += hash[no]
end
hash[no] = total
end
if hash.select{|key, val| val >= 1000000}.empty?
p "NA"
else
hash.each{ |key, val|
if val >= 1000000
p key
end
}
end
end
|
while true
hash = Hash.new
n = gets.to_i #???????????°
break if n == 0
for r in 0...n do
line = gets.chomp!
line = line.split
no = line[0].to_i #????????????
unitPrice = line[1].to_i #????£???????
quantity = line[2].to_i #?£??????°???
total = unitPrice * quantity #?°??¨?
if hash.key?(no)
total += hash[no]
end
hash[no] = total
end
if hash.select{|key, val| val >= 1000000}.empty?
puts "NA"
else
hash.each{ |key, val|
if val >= 1000000
p key
end
}
end
end
|
[["-", 8, 170, 0, 121, 64, 749, 0, 652, 735, 22], ["+", 8, 170, 0, 121, 64, 749, 0, 652, 735, 22]]
| 4
| 129
| 2
|
loop {
n = gets.to_i
break if n == 0
total = Hash.new(0)
n.times {
i, p, k = gets.split.map(&:to_i)
total[i] += p * k
}
a = total.keys.select{|i| total[i] >= 1000000}.sort
puts a.empty? ? "NA" : a
}
|
loop {
n = gets.to_i
break if n == 0
total = Hash.new(0)
n.times {
i, p, k = gets.split.map(&:to_i)
total[i] += p * k
}
a = total.keys.select{|i| total[i] >= 1000000}
puts a.empty? ? "NA" : a
}
|
[["-", 196, 196, 8, 734, 0, 662, 12, 652, 17, 131], ["-", 196, 196, 8, 734, 0, 662, 12, 652, 735, 22]]
| 4
| 79
| 2
|
loop do
n = gets.to_i
break if n.zero?
totals = Hash.new(0)
n.times do
e, p, q = gets.split.map(&:to_i)
totals[e] += p * q
end
employees = totals.select { |_, total| total >= 1_000_000 }.keys.sort
if employees.empty?
puts 'NA'
else
puts employees.sort.join("\n")
end
end
|
loop do
n = gets.to_i
break if n.zero?
totals = Hash.new(0)
n.times do
e, p, q = gets.split.map(&:to_i)
totals[e] += p * q
end
employees = totals.select { |_, total| total >= 1_000_000 }.keys
if employees.empty?
puts 'NA'
else
puts employees.join("\n")
end
end
|
[["-", 196, 737, 8, 736, 0, 662, 12, 652, 17, 131], ["-", 196, 737, 8, 736, 0, 662, 12, 652, 735, 22], ["-", 0, 652, 3, 4, 0, 652, 486, 652, 17, 131], ["-", 0, 652, 3, 4, 0, 652, 486, 652, 735, 22]]
| 4
| 89
| 4
|
while n = gets.chomp.to_i
break if n.zero?
sales = Hash.new{0}
n.times do
e, p, q = gets.chomp.split.map(&:to_i)
sales[e] += p * q
end
achieved = sales.select{|k, v| v >= 1_000_000}
achieved.each{|k, v| puts k}
puts 'NA' unless achieved.empty?
end
|
while n = gets.chomp.to_i
break if n.zero?
sales = Hash.new{0}
n.times do
e, p, q = gets.chomp.split.map(&:to_i)
sales[e] += p * q
end
achieved = sales.select{|k, v| v >= 1_000_000}
achieved.each{|k, v| puts k}
puts 'NA' if achieved.empty?
end
|
[["-", 0, 493, 0, 89, 8, 170, 0, 745, 0, 747], ["+", 0, 493, 0, 89, 8, 170, 0, 751, 0, 121]]
| 4
| 87
| 2
|
while 0<n=gets.to_i
h={};(1..n).map{a,b,c=gets.split.map &:to_i;h[a]||=0;h[a]+=b*c};h=h.reject{|a,x|x<1e6}.map{|a,x|a}.sort;h[0]||h.push("NA");puts h;end
|
while 0<n=gets.to_i
h={};(1..n).map{a,b,c=gets.split.map &:to_i;h[a]||=0;h[a]+=b*c};h=h.reject{|a,x|x<1e6}.map{|a,x|a};h[0]||h.push("NA");puts h;end
|
[["-", 0, 89, 8, 170, 0, 662, 12, 652, 17, 131], ["-", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22]]
| 4
| 98
| 13
|
loop do
n = gets.to_i
break if n.zero?
dataset = Hash.new
dataset.default = 0
n.times do
id, selling_price, quantity = gets.chomp.split.map(&:to_i)
dataset[id] += selling_price * quantity
end
satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys.join(?\n)
puts (satisfying_id.empty? ? "NA" : satisfying_id.sort)
end
|
loop do
n = gets.to_i
break if n.zero?
dataset = Hash.new
dataset.default = 0
n.times do
id, selling_price, quantity = gets.chomp.split.map(&:to_i)
dataset[id] += selling_price * quantity
end
satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys.join(?\n)
puts (satisfying_id.empty? ? "NA" : satisfying_id)
end
|
[["-", 3, 4, 0, 739, 0, 754, 75, 652, 17, 131], ["-", 3, 4, 0, 739, 0, 754, 75, 652, 735, 22]]
| 4
| 89
| 10
|
while True:
time=eval(input())
if time==0:
break
worr={}
mem=[]
for i in range(time):
shain=list(map(int, input().split()))
if shain[0] not in worr:
worr[shain[0]]=shain[1]*shain[2]
mem.append(shain[0])
else:
worr[shain[0]]+=shain[1]*shain[2]
mem.sort()
check=1
for i in mem:
if worr[i]>=1000000:
print(i)
check=0
if check==1:
print("NA")
|
while True:
time=eval(input())
if time==0:
break
worr={}
mem=[]
for i in range(time):
shain=list(map(int, input().split()))
if shain[0] not in worr:
worr[shain[0]]=shain[1]*shain[2]
mem.append(shain[0])
else:
worr[shain[0]]+=shain[1]*shain[2]
check=1
for i in mem:
if worr[i]>=1000000:
print(i)
check=0
if check==1:
print("NA")
|
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
| 5
| 143
| 5
|
while 1:
a={};b=0
n=int(input())
if n==0:break
for _ in[0]*n:
e,p,q=map(int,input().split())
a.setdefault(e,0);a[e]+=p*q
for e in a:
if a[e]>=1e6:print(e);b=1
if b:print('NA')
|
while 1:
a={};b=1
n=int(input())
if n==0:break
for _ in[0]*n:
e,p,q=map(int,input().split())
a.setdefault(e,0);a[e]+=p*q
for e in a:
if a[e]>=1e6:print(e);b=0
if b:print('NA')
|
[["-", 0, 52, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 52, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
| 5
| 99
| 4
|
import sys
while True:
a=int(eval(input()))
if a==0: break
ans,name1,name2=[],[],[]
hogehoge=0
for i in range(a):
hoge=list(map(int,input().split()))
if hoge[0] in name2:
ww = hoge[1]*hoge[2]
r = name2.index(hoge[0])
if len(ans[r]+ww) >= 7:
hogehoge+=1
name1.append(hoge[0])
else:
ans[r]+=ww
else:
qq = hoge[1]*hoge[2]
if len(str(qq)) >= 7:
hogehoge+=1
name1.append(hoge[0])
else:
name2.append(hoge[0])
ans.append(qq)
if hogehoge == 0: print("NA")
else:
for i in range(len(name1)):
print(name1[i])
|
import sys
while True:
a=int(eval(input()))
if a==0: break
ans,name1,name2=[],[],[]
hogehoge=0
for i in range(a):
hoge=list(map(int,input().split()))
if hoge[0] in name2:
ww = hoge[1]*hoge[2]
r = name2.index(hoge[0])
if len(str(ans[r]+ww)) >= 7:
hogehoge+=1
name1.append(hoge[0])
else:
ans[r]+=ww
else:
qq = hoge[1]*hoge[2]
if len(str(qq)) >= 7:
hogehoge+=1
name1.append(hoge[0])
else:
name2.append(hoge[0])
ans.append(qq)
if hogehoge == 0: print("NA")
else:
for i in range(len(name1)):
print(name1[i])
|
[["+", 15, 666, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
| 5
| 211
| 3
|
import sys
from Config import DB
def add(lis,check_list):
for index in range(len(lis)):
if lis[index][0]==check_list[0]:
lis[index][1]+=int(check_list[1])*int(check_list[2])
return
lis.append([check_list[0],int(check_list[1])*int(check_list[2])])
while True:
num=int(input())
if num==0: break
lis=[]
for i in range(num):
l=input().split(" ")
add(lis,l)
c=0
for ele in lis:
if ele[1]>=1000000:
print(ele[0])
c+=1
if c==0: print("NA")
|
def add(lis,check_list):
for index in range(len(lis)):
if lis[index][0]==check_list[0]:
lis[index][1]+=int(check_list[1])*int(check_list[2])
return
lis.append([check_list[0],int(check_list[1])*int(check_list[2])])
while True:
num=int(input())
if num==0: break
lis=[]
for i in range(num):
l=input().split(" ")
add(lis,l)
c=0
for ele in lis:
if ele[1]>=1000000:
print(ele[0])
c+=1
if c==0: print("NA")
|
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["-", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["-", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]]
| 5
| 174
| 6
|
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');
var line;
while (line = lines.shift()) {
console.log(line.replace(/Hoshino/g, 'Hoshina'));
}
|
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');
lines.shift();
var line;
while (line = lines.shift()) {
console.log(line.replace(/Hoshino/g, 'Hoshina'));
}
|
[["+", 0, 493, 0, 1, 0, 2, 63, 558, 500, 22], ["+", 0, 493, 0, 1, 0, 2, 63, 558, 0, 131], ["+", 0, 493, 0, 1, 0, 2, 63, 558, 559, 560], ["+", 0, 493, 0, 1, 0, 2, 3, 3, 0, 24], ["+", 0, 493, 0, 1, 0, 2, 3, 3, 0, 25], ["+", 36, 36, 36, 36, 0, 493, 0, 1, 0, 35]]
| 2
| 71
| 6
|
<?php
$n = fgets(STDIN);
for ($i = 0; $i < $n; $i++) {
$line = trim(fgets(STDIN));
echo str_replace("Hoshino", "Hoshina", $line);
}
|
<?php
$n = fgets(STDIN);
for ($i = 0; $i < $n; $i++) {
$line = fgets(STDIN);
echo str_replace("Hoshino", "Hoshina", $line);
}
|
[["-", 0, 9, 0, 1, 0, 11, 12, 613, 63, 141], ["-", 0, 1, 0, 11, 12, 613, 3, 3, 0, 24], ["-", 3, 3, 0, 28, 0, 613, 3, 3, 0, 25]]
| 6
| 54
| 3
|
<?php
$inputCount = getStdin();
for ($i = 0; $i < $inputCount; $i++) {
echo str_replace('Hoshino', 'Hoshina', getStdin());
}
function getStdin()
{
return trim(fgets(STDIN));
}
function explodeStdin()
{
return explode(' ', getStdin());
}
|
<?php
$inputCount = getStdin();
for ($i = 0; $i < $inputCount; $i++) {
echo str_replace('Hoshino', 'Hoshina', fgets(STDIN));
}
function getStdin()
{
return trim(fgets(STDIN));
}
function explodeStdin()
{
return explode(' ', getStdin());
}
|
[["-", 0, 613, 3, 3, 0, 28, 0, 613, 63, 141], ["+", 0, 613, 3, 3, 0, 28, 0, 613, 63, 141], ["+", 0, 28, 0, 613, 3, 3, 0, 28, 0, 141]]
| 6
| 76
| 3
|
import java.util.Scanner;
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for (int i = 0; i < t; i++) {
String s = sc.nextLine();
s = s.replaceAll("Hoshino", "Hishina");
System.out.println(s);
}
}
public static void main(String[] args) { new Main().run(); }
}
|
import java.util.Scanner;
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for (int i = 0; i < t; i++) {
String s = sc.nextLine();
s = s.replaceAll("Hoshino", "Hoshina");
System.out.println(s);
}
}
public static void main(String[] args) { new Main().run(); }
}
|
[["-", 0, 11, 12, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 11, 12, 492, 3, 4, 0, 5, 0, 491]]
| 3
| 114
| 2
|
#include <iostream>
#include <string>
using namespace std;
int N, c1, c2, c3, out, ret;
string S;
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
c1 = 0, c2 = 0, c3 = 0, out = 0, ret = 0;
while (out != 3) {
cin >> S;
if (S == "HIT") {
ret += c3, c3 = c2, c2 = c1, c1 = 1;
} else if (S == "HOMERUN") {
ret += c1 + c2 + c3, c1 = 0, c2 = 0, c3 = 0;
} else {
out++;
}
}
printf("%d\n", ret);
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int N, c1, c2, c3, out, ret;
string S;
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
c1 = 0, c2 = 0, c3 = 0, out = 0, ret = 0;
while (out != 3) {
cin >> S;
if (S == "HIT") {
ret += c3, c3 = c2, c2 = c1, c1 = 1;
} else if (S == "HOMERUN") {
ret += c1 + c2 + c3 + 1, c1 = 0, c2 = 0, c3 = 0;
} else {
out++;
}
}
printf("%d\n", ret);
}
return 0;
}
|
[["+", 0, 1, 0, 34, 31, 11, 12, 16, 17, 72], ["+", 0, 1, 0, 34, 31, 11, 12, 16, 12, 13]]
| 1
| 164
| 2
|
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define CI cin >>
#define CO cout <<
#define E << endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;
string c;
string sA, strB;
vector<string> city;
vector<int> population;
void input() { CI c; }
int main(void) {
int HIT = 0;
int OUT = 0;
bool HOMERUN = false;
int point = 0;
CI n;
REP(i, 2) {
while (true) {
CI c;
if (c == "HIT") {
HIT++;
}
if (c == "OUT") {
OUT++;
}
if (c == "HOMERUN") {
HOMERUN = true;
}
if (HIT == 4) {
point++;
HIT--;
}
if (HOMERUN == true) {
point += HIT + 1;
HIT = 0;
HOMERUN = false;
}
if (OUT == 3) {
HIT = 0;
OUT = 0;
break;
}
}
CO point E point = 0;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define CI cin >>
#define CO cout <<
#define E << endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;
string c;
string sA, strB;
vector<string> city;
vector<int> population;
void input() { CI c; }
int main(void) {
int HIT = 0;
int OUT = 0;
bool HOMERUN = false;
int point = 0;
CI n;
REP(i, n) {
while (true) {
CI c;
if (c == "HIT") {
HIT++;
}
if (c == "OUT") {
OUT++;
}
if (c == "HOMERUN") {
HOMERUN = true;
}
if (HIT == 4) {
point++;
HIT--;
}
if (HOMERUN == true) {
point += HIT + 1;
HIT = 0;
HOMERUN = false;
}
if (OUT == 3) {
HIT = 0;
OUT = 0;
break;
}
}
CO point E point = 0;
}
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
| 1
| 378
| 3
|
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define syosu(x) fixed << setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const double pi = acos(-1);
const double eps = 1e-8;
int n;
string str;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int out = 0, ans = 0;
vector<bool> base(3);
while (out < 3) {
cin >> str;
if (str == "OUT")
out++;
else if (str == "HIT") {
for (int j = 2; j >= 0; j--) {
if (base[j]) {
if (j + 1 > 2)
ans++;
else
base[j + 1] = 1;
base[j] = 0;
}
}
base[0] = 1;
} else {
for (int j = 0; j < 3; j++) {
if (base[j])
ans++;
base[j] == 0;
}
}
}
cout << ans << endl;
}
}
|
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define syosu(x) fixed << setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const double pi = acos(-1);
const double eps = 1e-8;
int n;
string str;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int out = 0, ans = 0;
vector<bool> base(3);
while (out < 3) {
cin >> str;
if (str == "OUT")
out++;
else if (str == "HIT") {
for (int j = 2; j >= 0; j--) {
if (base[j]) {
if (j + 1 > 2)
ans++;
else
base[j + 1] = 1;
base[j] = 0;
}
}
base[0] = 1;
} else {
for (int j = 0; j < 3; j++) {
if (base[j])
ans++;
base[j] = 0;
}
ans++;
}
}
cout << ans << endl;
}
}
|
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
| 1
| 314
| 5
|
#include <iostream>
#include <string>
int main() {
int n;
int base[3];
int out, score;
std::string event;
std::cin >> n;
for (int i = 0; i < n; i++) {
base[0] = 0;
base[1] = 0;
base[2] = 0;
out = 0;
score = 0;
while (out != 3) {
std::cin >> event;
if (event == "HIT") {
if (base[2] >= 1) {
base[2]--;
score++;
}
if (base[1] >= 1) {
base[1]--;
base[2]++;
}
if (base[0] >= 1) {
base[0]--;
base[1]++;
}
base[0]++;
} else if (event == "HOMERUN") {
score += base[2];
base[2] = 0;
score += base[1];
base[1] = 0;
score += base[0];
base[0] = 0;
} else {
out++;
}
}
std::cout << score << std::endl;
}
return 0;
}
|
#include <iostream>
#include <string>
int main() {
int n;
int base[3];
int out, score;
std::string event;
std::cin >> n;
for (int i = 0; i < n; i++) {
base[0] = 0;
base[1] = 0;
base[2] = 0;
out = 0;
score = 0;
while (out != 3) {
std::cin >> event;
if (event == "HIT") {
if (base[2] >= 1) {
base[2]--;
score++;
}
if (base[1] >= 1) {
base[1]--;
base[2]++;
}
if (base[0] >= 1) {
base[0]--;
base[1]++;
}
base[0]++;
} else if (event == "HOMERUN") {
score++;
score += base[2];
base[2] = 0;
score += base[1];
base[1] = 0;
score += base[0];
base[0] = 0;
} else {
out++;
}
}
std::cout << score << std::endl;
}
return 0;
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
| 1
| 248
| 3
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int out = 0;
int r1 = 0;
int r2 = 0;
int r3 = 0;
int t = 0;
string k;
int a = 0;
cin >> a;
for (int i = 1; i <= a; i++) {
out = 0;
t = 0;
r1 = 0;
r2 = 0;
r3 = 0;
while (out != 3) {
cin >> k;
if (k == "OUT") {
out++;
}
if (k == "HIT") {
if (r3 == 1) {
t++;
r3 = 0;
}
if (r2 == 1) {
r3 = 1;
r2 = 0;
}
if (r1 == 1) {
r2 = 1;
r1 = 0;
}
}
if (k == "HOMERUN") {
if (r3 == 1) {
t++;
r3 = 0;
}
if (r2 == 1) {
t++;
r2 = 0;
}
if (r1 == 1) {
t++;
r1 = 0;
}
t++;
}
}
cout << t << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int out = 0;
int r1 = 0;
int r2 = 0;
int r3 = 0;
int t = 0;
string k;
int a = 0;
cin >> a;
for (int i = 1; i <= a; i++) {
out = 0;
t = 0;
r1 = 0;
r2 = 0;
r3 = 0;
while (out != 3) {
cin >> k;
if (k == "OUT") {
out++;
}
if (k == "HIT") {
if (r3 == 1) {
t++;
r3 = 0;
}
if (r2 == 1) {
r3 = 1;
r2 = 0;
}
if (r1 == 1) {
r2 = 1;
r1 = 0;
}
r1 = 1;
}
if (k == "HOMERUN") {
if (r3 == 1) {
t++;
r3 = 0;
}
if (r2 == 1) {
t++;
r2 = 0;
}
if (r1 == 1) {
t++;
r1 = 0;
}
t++;
}
}
cout << t << endl;
}
return 0;
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
| 1
| 236
| 4
|
#include <iostream>
#include <string>
#include <valarray>
using namespace std;
int main(void) {
int n;
cin >> n;
while (n--) {
string s;
valarray<int> h(3);
int o = 0;
int sc = 0;
h = 0;
while (o != 3) {
cin >> s;
if (s[0] == 'O')
o++;
else if (s[1] == 'I') {
sc += h[2];
h = h.shift(1);
h[0] = 1;
} else {
sc += 1 + h.sum();
h = 0;
}
}
cout << sc << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
#include <valarray>
using namespace std;
int main(void) {
int n;
cin >> n;
while (n--) {
string s;
valarray<int> h(3);
int o = 0;
int sc = 0;
h = 0;
while (o != 3) {
cin >> s;
if (s[0] == 'O')
o++;
else if (s[1] == 'I') {
sc += h[2];
h = h.shift(-1);
h[0] = 1;
} else {
sc += 1 + h.sum();
h = 0;
}
}
cout << sc << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13]]
| 1
| 146
| 2
|
#include "bits/stdc++.h"
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i)
#define ALL(v) (v).begin(), (v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define DUMP(v) \
REP(i, (v).size()) { \
cout << v[i]; \
if (i != v.size() - 1) \
cout << " "; \
else \
cout << endl; \
}
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
REP(i, n) {
int out = 0, score = 0;
vi v(3, 0);
while (out < 3) {
string s;
cin >> s;
if (s[0] == 'H') {
RREP(i, 3) {
if (v[i] == 1) {
if (i == 2)
score++;
else
v[i + 1]++;
v[i]--;
}
}
v[0]++;
} else if (s[0] == 'O') {
out++;
} else {
REP(i, 3) {
if (v[i] == 1) {
score++;
v[i] = 0;
}
}
score++;
}
}
cout << score << endl;
}
return 0;
}
|
#include "bits/stdc++.h"
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i)
#define ALL(v) (v).begin(), (v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define DUMP(v) \
REP(i, (v).size()) { \
cout << v[i]; \
if (i != v.size() - 1) \
cout << " "; \
else \
cout << endl; \
}
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
REP(j, n) {
int out = 0, score = 0;
vi v(3, 0);
while (out < 3) {
string s;
cin >> s;
if (s == "HIT") {
RREP(i, 3) {
if (v[i] == 1) {
if (i == 2)
score++;
else
v[i + 1]++;
v[i]--;
}
}
v[0]++;
} else if (s[0] == 'O') {
out++;
} else {
REP(i, 3) {
if (v[i] == 1) {
score++;
v[i] = 0;
}
}
score++;
}
}
cout << score << endl;
}
return 0;
}
|
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 5, 0, 62], ["+", 0, 57, 15, 339, 51, 16, 12, 5, 0, 6]]
| 1
| 414
| 11
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
vector<int> base(3, 0);
int res = 0;
int out = 0;
while (out != 3) {
string s;
cin >> s;
if (s == "HIT") {
res += base[2];
base[2] = base[1];
base[1] = base[0];
base[0] = 1;
}
if (s == "OUT") {
out++;
}
if (s == "HOMERUN") {
res += base[0] + base[1] + base[2];
for (int i = 0; i < 3; i++)
base[i] = 0;
}
}
cout << res << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
vector<int> base(3, 0);
int res = 0;
int out = 0;
while (out != 3) {
string s;
cin >> s;
if (s == "HIT") {
res += base[2];
base[2] = base[1];
base[1] = base[0];
base[0] = 1;
}
if (s == "OUT") {
out++;
}
if (s == "HOMERUN") {
res += base[0] + base[1] + base[2] + 1;
for (int i = 0; i < 3; i++)
base[i] = 0;
}
}
cout << res << endl;
}
return 0;
}
|
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
| 1
| 185
| 2
|
#include <iostream>
using namespace std;
int main(void) {
int n;
cin >> n;
char c[8];
int i = 0;
int out = 0;
int array[3] = {};
int score = 0;
while (i != n) {
cin >> c;
if (c[0] == 'H' && c[1] == 'I' && c[2] == 'T') {
if (array[2] == 1) {
score++;
}
array[2] = array[1];
array[1] = array[0];
array[0] = 1;
}
if (c[0] == 'H' && c[1] == 'O' && c[2] == 'M' && c[3] == 'E' &&
c[4] == 'R' && c[5] == 'A' && c[6] == 'N') {
score = score + array[0] + array[1] + array[2] + 1;
array[0] = 0;
array[1] = 0;
array[2] = 0;
}
if (c[0] == 'O' && c[1] == 'U' && c[2] == 'T') {
out++;
}
if (out == 3) {
cout << score << endl;
array[0] = 0;
array[1] = 0;
array[2] = 0;
score = 0;
out = 0;
i++;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(void) {
int n;
cin >> n;
char c[8];
int i = 0;
int out = 0;
int array[3] = {};
int score = 0;
while (i != n) {
cin >> c;
if (c[0] == 'H' && c[1] == 'I' && c[2] == 'T') {
if (array[2] == 1) {
score++;
}
array[2] = array[1];
array[1] = array[0];
array[0] = 1;
}
if (c[0] == 'H' && c[1] == 'O' && c[2] == 'M' && c[3] == 'E' &&
c[4] == 'R' && c[5] == 'U' && c[6] == 'N') {
score = score + array[0] + array[1] + array[2] + 1;
array[0] = 0;
array[1] = 0;
array[2] = 0;
}
if (c[0] == 'O' && c[1] == 'U' && c[2] == 'T') {
out++;
}
if (out == 3) {
cout << score << endl;
array[0] = 0;
array[1] = 0;
array[2] = 0;
score = 0;
out = 0;
i++;
}
}
return 0;
}
|
[["-", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125], ["+", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 326
| 2
|
#include <iostream>
#include <queue>
#include <string>
using namespace std;
class Player {
private:
int base;
public:
Player(int i) { base = 1; }
void SetBase(int a) { this->base = a; }
int GetBase() { return this->base; }
};
class Baseball {
private:
int score;
int out;
queue<Player> que;
public:
Baseball() { score = out = 0; }
void add_hit(int num) {
Player one(1);
this->que.push(one);
int length = this->que.size();
for (int i = 0; i < length; i++) {
Player tmp = this->que.front();
this->que.pop();
int tmp_base = tmp.GetBase();
if ((tmp_base + num) > 4) {
score++;
} else {
tmp.SetBase(tmp_base + num);
this->que.push(tmp);
}
}
}
void add_out() { this->out++; }
void add_score() { this->score++; }
int GetOut() { return this->out; }
int GetScore() { return this->score; }
void show_score() { cout << this->score << endl; }
};
int main(void) {
int time;
cin >> time;
for (int i = 0; i < time; i++) {
Baseball baseball;
while (baseball.GetOut() != 3) {
string judge;
cin >> judge;
if (judge == "HIT") {
baseball.add_hit(1);
} else if (judge == "OUT") {
baseball.add_out();
} else if (judge == "HOMERUN") {
baseball.add_score();
}
}
cout << baseball.GetScore() << endl;
}
return 0;
}
|
#include <iostream>
#include <queue>
#include <string>
using namespace std;
class Player {
private:
int base;
public:
Player(int i) { base = 1; }
void SetBase(int a) { this->base = a; }
int GetBase() { return this->base; }
};
class Baseball {
private:
int score;
int out;
queue<Player> que;
public:
Baseball() { score = out = 0; }
void add_hit(int num) {
Player one(1);
this->que.push(one);
int length = this->que.size();
for (int i = 0; i < length; i++) {
Player tmp = this->que.front();
this->que.pop();
int tmp_base = tmp.GetBase();
if ((tmp_base + num) > 4) {
score++;
} else {
tmp.SetBase(tmp_base + num);
this->que.push(tmp);
}
}
}
void add_out() { this->out++; }
void add_score() { this->score++; }
int GetOut() { return this->out; }
int GetScore() { return this->score; }
void show_score() { cout << this->score << endl; }
};
int main(void) {
int time;
cin >> time;
for (int i = 0; i < time; i++) {
Baseball baseball;
while (baseball.GetOut() != 3) {
string judge;
cin >> judge;
if (judge == "HIT") {
baseball.add_hit(1);
} else if (judge == "OUT") {
baseball.add_out();
} else if (judge == "HOMERUN") {
baseball.add_hit(4);
}
}
cout << baseball.GetScore() << endl;
}
return 0;
}
|
[["-", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 378
| 3
|
#include <cstdio>
#include <cstring>
int singlehit(char *base, int score);
int homerun(char *base, int score);
int main(void) {
int number;
scanf("%d", &number);
char event[10];
int out_num;
char base[4];
while (number != -1) {
int score = 0;
for (int i = 0; i < 4; i++) {
base[i] = '0';
}
for (out_num = 0; out_num != 3;) {
scanf("%s", event);
if (strcmp(event, "HIT") == 0) {
score = singlehit(base, score);
} else if (strcmp(event, "HOMERUN") == 0) {
score = homerun(base, score);
} else {
out_num++;
}
}
printf("%d\n", score);
number--;
}
return (0);
}
int singlehit(char *base, int score) {
base[1]++;
if (base[1] == '2') {
base[2]++;
base[1]--;
}
if (base[2] == '2') {
base[3]++;
base[2]--;
}
if (base[3] == '2') {
score++;
base[3]--;
}
return (score);
}
int homerun(char base[], int score) {
for (int i = 0; i < 4; i++) {
if (base[i] == '1') {
score++;
base[i] = '0';
}
}
score++;
return (score);
}
|
#include <cstdio>
#include <cstring>
int singlehit(char *base, int score);
int homerun(char *base, int score);
int main(void) {
int number;
scanf("%d", &number);
char event[10];
int out_num;
char base[4];
while (number != 0) {
int score = 0;
for (int i = 0; i < 4; i++) {
base[i] = '0';
}
for (out_num = 0; out_num != 3;) {
scanf("%s", event);
if (strcmp(event, "HIT") == 0) {
score = singlehit(base, score);
} else if (strcmp(event, "HOMERUN") == 0) {
score = homerun(base, score);
} else {
out_num++;
}
}
printf("%d\n", score);
number--;
}
return (0);
}
int singlehit(char *base, int score) {
base[1]++;
if (base[1] == '2') {
base[2]++;
base[1]--;
}
if (base[2] == '2') {
base[3]++;
base[2]--;
}
if (base[3] == '2') {
score++;
base[3]--;
}
return (score);
}
int homerun(char base[], int score) {
for (int i = 0; i < 4; i++) {
if (base[i] == '1') {
score++;
base[i] = '0';
}
}
score++;
return (score);
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13]]
| 1
| 351
| 2
|
#include <stdio.h>
int main(void) {
int i, j, k, q, p, inning, point, kazu[20];
char eve[10];
point = 0;
j = 0;
k = 0;
q = 0;
p = 0;
scanf("%d", &inning);
for (k = 0; k < inning; k++) {
point = 0;
j = 0;
q = 0;
p = 0;
while (q < 3) {
for (j = 0; j < 10; j++) {
eve[j] = 0;
}
scanf("%s", eve);
if (eve[0] == 'O') {
if (eve[1] == 'U') {
if (eve[2] == 'T') {
q++;
}
}
}
if (eve[0] == 'H') {
if (eve[1] == 'I') {
if (eve[2] == 'T') {
p++;
if (p >= 4) {
point++;
}
}
}
}
if (eve[0] == 'H') {
if (eve[1] == 'O') {
if (eve[2] == 'M') {
if (eve[3] == 'E') {
if (eve[4] == 'R') {
if (eve[5] == 'U') {
if (eve[6] == 'N') {
point = point + p + 1;
p = 0;
}
}
}
}
}
}
}
}
kazu[k] = point;
}
for (k = 0; k < inning; k++) {
printf("%d\n", kazu[k]);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int i, j, k, q, p, inning, point, kazu[20];
char eve[10];
point = 0;
j = 0;
k = 0;
q = 0;
p = 0;
scanf("%d", &inning);
for (k = 0; k < inning; k++) {
point = 0;
j = 0;
q = 0;
p = 0;
while (q < 3) {
for (j = 0; j < 10; j++) {
eve[j] = 0;
}
scanf("%s", eve);
if (eve[0] == 'O') {
if (eve[1] == 'U') {
if (eve[2] == 'T') {
q++;
}
}
}
if (eve[0] == 'H') {
if (eve[1] == 'I') {
if (eve[2] == 'T') {
p++;
if (p >= 4) {
point++;
p--;
}
}
}
}
if (eve[0] == 'H') {
if (eve[1] == 'O') {
if (eve[2] == 'M') {
if (eve[3] == 'E') {
if (eve[4] == 'R') {
if (eve[5] == 'U') {
if (eve[6] == 'N') {
point = point + p + 1;
p = 0;
}
}
}
}
}
}
}
}
kazu[k] = point;
}
for (k = 0; k < inning; k++) {
printf("%d\n", kazu[k]);
}
return 0;
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["+", 64, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
| 1
| 371
| 3
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int i, n, point = 0;
bool run[3];
string s;
cin >> n;
int out = 3;
while (n--) {
for (i = 0; i < 3; i++)
run[i] = 0;
point = 0;
out = 3;
while (out) {
cin >> s;
if (s == "HIT") {
if (run[2])
point++;
for (i = 2; i > 0; i--)
run[i] = run[i - 1];
run[0] = 1;
} else if (s == "HOMERUN") {
for (i = 0; i > 3; i++)
if (run[i]) {
point++;
run[i] = 0;
}
point++;
} else
out--;
}
cout << point << "\n";
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int i, n, point = 0;
bool run[3];
string s;
cin >> n;
int out = 3;
while (n--) {
for (i = 0; i < 3; i++)
run[i] = 0;
point = 0;
out = 3;
while (out) {
cin >> s;
if (s == "HIT") {
if (run[2])
point++;
for (i = 2; i > 0; i--)
run[i] = run[i - 1];
run[0] = 1;
} else if (s == "HOMERUN") {
for (i = 0; i < 3; i++)
if (run[i]) {
point++;
run[i] = 0;
}
point++;
} else
out--;
}
cout << point << endl;
}
return 0;
}
|
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 44], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 199
| 6
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string instr;
int N;
cin >> N;
while (N--, N >= 0) {
int out = 0;
int pos[4] = {};
while (out < 3) {
cin >> instr;
if (instr == "HIT") {
if (pos[2]) {
pos[3] += pos[2];
pos[2] = 0;
}
swap(pos[2], pos[1]);
swap(pos[1], pos[0]);
pos[0] = 1;
} else if (instr == "HOMERUN") {
pos[3] += pos[0] + pos[1] + pos[2];
pos[0] = pos[1] = pos[2] = 0;
} else if (instr == "OUT")
out++;
// cout << pos[0] << ' ' << pos[1] << ' ' << pos[2] << ' '
//<< pos[3] << endl;
}
cout << pos[3] << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string instr;
int N;
cin >> N;
while (N--, N >= 0) {
int out = 0;
int pos[4] = {};
while (out < 3) {
cin >> instr;
if (instr == "HIT") {
if (pos[2]) {
pos[3] += pos[2];
pos[2] = 0;
}
swap(pos[2], pos[1]);
swap(pos[1], pos[0]);
pos[0] = 1;
} else if (instr == "HOMERUN") {
pos[3] += pos[0] + pos[1] + pos[2] + 1;
pos[0] = pos[1] = pos[2] = 0;
} else if (instr == "OUT")
out++;
// cout << pos[0] << ' ' << pos[1] << ' ' << pos[2] << ' '
//<< pos[3] << endl;
}
cout << pos[3] << endl;
}
return 0;
}
|
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
| 1
| 207
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int a, b, c, d;
int score;
int out = 0;
int n;
cin >> n;
while (n--) {
score = a = b = c = d = 0;
string e;
while (out != 3) {
cin >> e;
if (e == "HIT") {
d = c;
c = b;
b = a;
a = 1;
score += d;
d = 0;
} else if (e == "HOMERUN") {
score += a + b + c + 1;
a = b = c = 0;
} else {
out++;
}
}
cout << score << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int a, b, c, d;
int score;
int out = 0;
int n;
cin >> n;
while (n--) {
score = a = b = c = d = 0;
out = 0;
string e;
while (out != 3) {
cin >> e;
if (e == "HIT") {
d = c;
c = b;
b = a;
a = 1;
score += d;
d = 0;
} else if (e == "HOMERUN") {
score += a + b + c + 1;
a = b = c = 0;
} else {
out++;
}
}
cout << score << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 150
| 4
|
#include <iostream>
#include <string>
int main(void) {
int datasets, i, hit = 0, out, remain = 0;
std::string input;
std::cin >> datasets;
for (i = 0; i < datasets; ++i) {
out = 0;
while (out < 3) {
std::cin >> input;
if (input == "HIT") {
++hit;
++remain;
}
if (input == "HOMERUN") {
++hit;
remain = 0;
}
if (input == "OUT")
++out;
}
if (remain > 3)
remain = 3;
std::cout << hit - remain;
hit = 0;
remain = 0;
}
return 0;
}
|
#include <iostream>
#include <string>
int main(void) {
int datasets, i, hit = 0, out, remain = 0;
std::string input;
std::cin >> datasets;
for (i = 0; i < datasets; ++i) {
out = 0;
while (out < 3) {
std::cin >> input;
if (input == "HIT") {
++hit;
++remain;
}
if (input == "HOMERUN") {
++hit;
remain = 0;
}
if (input == "OUT")
++out;
}
if (remain > 3)
remain = 3;
std::cout << hit - remain << std::endl;
hit = 0;
remain = 0;
}
return 0;
}
|
[["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 0, 349], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 141, 22]]
| 1
| 143
| 4
|
#include <stdio.h>
#include <string.h>
int main(void) {
int i, run = 0, point = 0, out = 0;
char s[100];
scanf("%d", &i);
while (i != 0) {
scanf("%s", s);
if (strcmp(s, "HIT") == 0) {
run += 1;
if (run == 4) {
run = 0;
point += 1;
}
}
if (strcmp(s, "HOMERUN") == 0) {
point += run + 1;
run = 0;
}
if (strcmp(s, "OUT") == 0) {
out += 1;
if (out == 3) {
run = 0;
out = 0;
printf("%d\n", point);
point = 0;
i--;
}
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main(void) {
int i, run = 0, point = 0, out = 0;
char s[100];
scanf("%d", &i);
while (i != 0) {
scanf("%s", s);
if (strcmp(s, "HIT") == 0) {
run += 1;
if (run == 4) {
run = 3;
point += 1;
}
}
if (strcmp(s, "HOMERUN") == 0) {
point += run + 1;
run = 0;
}
if (strcmp(s, "OUT") == 0) {
out += 1;
if (out == 3) {
run = 0;
out = 0;
printf("%d\n", point);
point = 0;
i--;
}
}
}
return 0;
}
|
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
| 1
| 174
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
string b;
cin >> n;
for (int i = 0; i < n; i++) {
int out = 0;
int sco = 0;
int rui[3] = {0};
while (out != 3) {
cin >> b;
if (b == "OUT") {
out++;
} else if (b == "HIT") {
for (int j = 2; j >= 0; j--) {
if (rui[j] == 1) {
if (j == 2) {
sco++;
rui[j] = 0;
} else {
rui[j + 1] = 1;
rui[j] = 0;
}
}
}
rui[0] = 1;
} else {
sco++;
for (int j = 0; j < 2; j++) {
if (rui[j] == 1) {
rui[j] = 0;
sco++;
}
}
}
}
cout << sco << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
string b;
cin >> n;
for (int i = 0; i < n; i++) {
int out = 0;
int sco = 0;
int rui[3] = {0};
while (out != 3) {
cin >> b;
if (b == "OUT") {
out++;
} else if (b == "HIT") {
for (int j = 2; j >= 0; j--) {
if (rui[j] == 1) {
if (j == 2) {
sco++;
rui[j] = 0;
} else {
rui[j + 1] = 1;
rui[j] = 0;
}
}
}
rui[0] = 1;
} else {
sco++;
for (int j = 0; j < 3; j++) {
if (rui[j] == 1) {
rui[j] = 0;
sco++;
}
}
}
}
cout << sco << endl;
}
return 0;
}
|
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 219
| 2
|
#include <iostream>
#include <queue>
#include <string>
class Baseball {
private:
std::queue<int> runner;
int out_count;
int score;
public:
void initRunner() {
while (runner.empty() != true) {
runner.pop();
}
for (int i = 0; i < 3; ++i) {
runner.push(0);
}
}
Baseball() {
out_count = 0;
score = 0;
initRunner();
}
~Baseball() {}
void hit() {
if (runner.back() == 1)
++score;
runner.pop();
runner.push(1);
}
void homerun() {
do {
if (runner.back() == 1)
++score;
runner.pop();
} while (runner.empty() != true);
++score;
initRunner();
}
int getScore() {
initRunner();
std::string str;
while (out_count != 3) {
std::cin >> str;
if (str == "HIT")
hit();
if (str == "HOMERUN")
homerun();
if (str == "OUT")
++out_count;
}
return score;
}
};
int main(void) {
int N;
std::cin >> N;
for (int i = 0; i < N; ++i) {
Baseball baseball;
std::cout << baseball.getScore() << std::endl;
}
}
|
#include <iostream>
#include <queue>
#include <string>
class Baseball {
private:
std::queue<int> runner;
int out_count;
int score;
public:
void initRunner() {
while (runner.empty() != true) {
runner.pop();
}
for (int i = 0; i < 3; ++i) {
runner.push(0);
}
}
Baseball() {
out_count = 0;
score = 0;
initRunner();
}
~Baseball() {}
void hit() {
if (runner.front() == 1)
++score;
runner.pop();
runner.push(1);
}
void homerun() {
do {
if (runner.front() == 1)
++score;
runner.pop();
} while (runner.empty() != true);
++score;
initRunner();
}
int getScore() {
initRunner();
std::string str;
while (out_count != 3) {
std::cin >> str;
if (str == "HIT")
hit();
if (str == "HOMERUN")
homerun();
if (str == "OUT")
++out_count;
}
return score;
}
};
int main(void) {
int N;
std::cin >> N;
for (int i = 0; i < N; ++i) {
Baseball baseball;
std::cout << baseball.getScore() << std::endl;
}
}
|
[["-", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120]]
| 1
| 293
| 4
|
gets.to_i.times{r=o=s=0
(c=gets[1];c<?O?(r+=1):c<?U?(s+=r+1;r=0):o+=1)while o<3
p s+r-3}
|
gets.to_i.times{r=o=s=0
(c=gets[1];c<?O?(r+=1):c<?U?(s+=r+1;r=0):o+=1)while o<3
p r<3?s:s+r-3}
|
[["+", 0, 652, 3, 4, 0, 754, 15, 738, 31, 22], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 17, 18], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 12, 612], ["+", 8, 734, 0, 652, 3, 4, 0, 754, 0, 101], ["+", 8, 734, 0, 652, 3, 4, 0, 754, 64, 22], ["+", 8, 734, 0, 652, 3, 4, 0, 754, 0, 102]]
| 4
| 62
| 6
|
result = []
file.gets.chomp.to_i.times do |inning|
score = 0
out = 0
runner = 0
while out < 3
event = file.gets.chomp
case event
when "HIT"
runner += 1
when "HOMERUN"
score += runner + 1
runner = 0
when "OUT"
out += 1
end
if runner == 4
score += 1
runner = 3
end
end
result[inning] = score
end
puts result
|
result = []
gets.chomp.to_i.times do |inning|
score = 0
out = 0
runner = 0
while out < 3
event = gets.chomp
case event
when "HIT"
runner += 1
when "HOMERUN"
score += runner + 1
runner = 0
when "OUT"
out += 1
end
if runner == 4
score += 1
runner = 3
end
end
result[inning] = score
end
puts result
|
[["-", 0, 652, 486, 652, 486, 652, 486, 652, 486, 22], ["-", 0, 652, 486, 652, 486, 652, 486, 652, 17, 131], ["-", 8, 170, 0, 662, 12, 652, 486, 652, 486, 22], ["-", 8, 170, 0, 662, 12, 652, 486, 652, 17, 131]]
| 4
| 87
| 4
|
class BaseBall
def initialize
@first=false
@second=false
@third=false
@out=0
end
def hit
if @third then
point=1
else
point=0
end
@third = false
@third = true if @second
@second = true if @first
@first = true
return point
end
def homerun
point= [@first,@second,@third].select{|x| x}.length + 1
@first,@second,@third =false
return point
end
def out
@out += 1
if @out>= 3 then
@out=0
return true
else
return false
end
end
end
if false then
fh=STDIN
else
fh=open("in0103.txt")
end
n= fh.gets.chomp.to_i
0.upto(n-1) { |i|
point=0
bb = BaseBall.new
while fh.gets do
s = $_.chomp
if s=="HIT" then
point += bb.hit
elsif s=="HOMERUN" then
point += bb.homerun
elsif s=="OUT" then
if bb.out then
puts point
break
end
end
end
}
|
class BaseBall
def initialize
@first=false
@second=false
@third=false
@out=0
end
def hit
if @third then
point=1
else
point=0
end
@third = false
@third = true if @second
@second = true if @first
@first = true
return point
end
def homerun
point= [@first,@second,@third].select{|x| x}.length + 1
@first,@second,@third =false
return point
end
def out
@out += 1
if @out>= 3 then
@out=0
return true
else
return false
end
end
end
if true then
fh=STDIN
else
fh=open("in0103.txt")
end
n= fh.gets.chomp.to_i
0.upto(n-1) { |i|
point=0
bb = BaseBall.new
while fh.gets do
s = $_.chomp
if s=="HIT" then
point += bb.hit
elsif s=="HOMERUN" then
point += bb.homerun
elsif s=="OUT" then
if bb.out then
puts point
break
end
end
end
}
|
[["-", 36, 36, 36, 36, 0, 493, 0, 121, 15, 147], ["+", 36, 36, 36, 36, 0, 493, 0, 121, 15, 146]]
| 4
| 201
| 2
|
left=gets.to_i
out,runner,score=0,0,0
while left>0
judge=gets.chomp
case judge
when "HIT" then
runner+=1
if runner>3 then
runner-=1
score+=1
end
when "OUT" then
out+=1
if out>=3 then
puts score
runner,score=0,0
left-=1
end
when "HOMERUN" then
score+=(runner+1)
runner=0
end
end
|
left=gets.to_i
out,runner,score=0,0,0
while left>0
judge=gets.chomp
case judge
when "HIT" then
runner+=1
if runner>3 then
runner-=1
score+=1
end
when "OUT" then
out+=1
if out>=3 then
puts score
runner,score,out=0,0,0
left-=1
end
when "HOMERUN" then
score+=(runner+1)
runner=0
end
end
|
[["+", 0, 121, 64, 749, 0, 662, 31, 761, 0, 21], ["+", 0, 121, 64, 749, 0, 662, 31, 761, 0, 22], ["+", 0, 121, 64, 749, 0, 662, 12, 762, 0, 612], ["+", 0, 121, 64, 749, 0, 662, 12, 762, 0, 21]]
| 4
| 90
| 4
|
import sys
#from me.io import dup_file_stdin
#@dup_file_stdin
def solve():
n = int(sys.stdin.readline())*3
s = 0
p = 0
while n>0:
log = sys.stdin.readline()
if "HIT" in log:
if p >= 3:
s += 1
p += 1
elif "OUT" in log:
n -= 1
if n % 3 == 0:
print(s)
s = 0
p = 0
if n == 0:
break
else:
s += p + 1
p = 0
solve()
|
import sys
#from me.io import dup_file_stdin
#@dup_file_stdin
def solve():
n = int(sys.stdin.readline())*3
s = 0
p = 0
while n>0:
log = sys.stdin.readline()
if "HIT" in log:
if p >= 3:
s += 1
else:
p += 1
elif "OUT" in log:
n -= 1
if n % 3 == 0:
print(s)
s = 0
p = 0
if n == 0:
break
else:
s += p + 1
p = 0
solve()
|
[["+", 0, 57, 64, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 76, 0, 102]]
| 5
| 107
| 2
|
for _ in[0]*int(input()):
r=o=s=0
while 1:
a=input()[1]
if'I'==a:
if r<3:r+=1
else:s+=1
elif'O'==a:s+=r+1;r=0
else:
if r<3:o+=1
else:print(s);break
|
for _ in[0]*int(input()):
r=o=s=0
while 1:
a=input()[1]
if'I'==a:
if r<3:r+=1
else:s+=1
elif'O'==a:s+=r+1;r=0
else:
if o<2:o+=1
else:print(s);break
|
[["-", 75, 76, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 75, 76, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 0, 612]]
| 5
| 86
| 13
|
inn=int(input())
o=0
i=0
s=[]
sc=0
ba=[]
while i<inn:
b=input()
if b == "OUT":
o+=1
if o%3 == 0 and o>0:
s.append(sc)
sc=0
i+=1
o=0
ba=[]
elif b == "HIT":
ba.append(1)
if len(ba)>=4:
sc+=1
ba=[1,1,1,1]
elif b == "HOMERUN":
ba.append(1)
sc+=len(ba)
ba=[]
[print(i) for i in s]
|
inn=int(input())
o=0
i=0
s=[]
sc=0
ba=[]
while i<inn:
b=input()
if b == "OUT":
o+=1
if o%3 == 0 and o>0:
s.append(sc)
sc=0
i+=1
o=0
ba=[]
elif b == "HIT":
ba.append(1)
if len(ba)>=4:
sc+=1
ba=[1,1,1]
elif b == "HOMERUN":
ba.append(1)
sc+=len(ba)
ba=[]
[print(i) for i in s]
|
[["-", 64, 196, 0, 1, 0, 662, 12, 634, 0, 21], ["-", 64, 196, 0, 1, 0, 662, 12, 634, 0, 612]]
| 5
| 143
| 2
|
<?php
while (true) {
$line = trim(fgets(STDIN));
list($H, $W) = explode(' ', $line);
if ($W == 0 && $H == 0) {
break;
}
$room = array();
for ($i = 0; $i < $H; $i++) {
$room[$i] = trim(fgets(STDIN));
}
$visited = array();
for ($i = 0; $i < $H; $i++) {
for ($j = 0; $j < $W; $j++) {
$visited[$i][$j] = false;
}
}
$x = 0; $y = 0;
$isLoop = false;
while (true) {
$line = $room[$y];
$dir = $line[$x];
if ($dir == '.') {
break;
}
$visited[$y][$x] = true;
switch ($dir) {
case '>':
$x++;
break;
case '<':
$x--;
break;
case 'v':
$y++;
break;
case '^':
$y--;
break;
}
if ($visited[$y][$x]) {
$isLoop = true;
break;
}
}
if ($isLoop) {
echo "LOOP";
} else {
echo "$x $y";
}
}
|
<?php
while (true) {
$line = trim(fgets(STDIN));
list($H, $W) = explode(' ', $line);
if ($W == 0 && $H == 0) {
break;
}
$room = array();
for ($i = 0; $i < $H; $i++) {
$room[$i] = trim(fgets(STDIN));
}
$visited = array();
for ($i = 0; $i < $H; $i++) {
for ($j = 0; $j < $W; $j++) {
$visited[$i][$j] = false;
}
}
$x = 0; $y = 0;
$isLoop = false;
while (true) {
$line = $room[$y];
$dir = $line[$x];
if ($dir == '.') {
break;
}
$visited[$y][$x] = true;
switch ($dir) {
case '>':
$x++;
break;
case '<':
$x--;
break;
case 'v':
$y++;
break;
case '^':
$y--;
break;
}
if ($visited[$y][$x]) {
$isLoop = true;
break;
}
}
if ($isLoop) {
echo "LOOP\n";
} else {
echo "$x $y\n";
}
}
|
[["+", 0, 57, 8, 9, 0, 608, 0, 609, 0, 44], ["+", 75, 76, 8, 9, 0, 608, 0, 609, 0, 44]]
| 6
| 316
| 2
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
if (line.isEmpty())
break;
String[] spl = line.split(" ");
int n1 = Integer.parseInt(spl[0]), n2 = Integer.parseInt(spl[1]);
if (n1 == 0 && n2 == 0) {
break;
}
String yuka[][] = new String[n1][n2];
for (int i = 0; i < n1; i++) {
line = br.readLine();
char spl2[] = line.toCharArray();
for (int j = 0; j < n2; j++) {
yuka[i][j] = spl2[j] + "";
}
}
int[] basyo = {0, 0};
while (true) {
String moji = yuka[basyo[0]][basyo[1]];
if (yuka[basyo[0]][basyo[1]].equals(".")) {
System.out.println(yuka[basyo[1]] + " " + yuka[basyo[0]]);
break;
}
if (yuka[basyo[0]][basyo[1]].equals("already")) {
System.out.println("LOOP");
break;
}
int hozon1 = basyo[0], hozon2 = basyo[1];
if (yuka[basyo[0]][basyo[1]].equals("<")) {
basyo[1]--;
}
if (yuka[basyo[0]][basyo[1]].equals(">")) {
basyo[1]++;
}
if (yuka[basyo[0]][basyo[1]].equals("^")) {
basyo[0]--;
}
if (yuka[basyo[0]][basyo[1]].equals("v")) {
basyo[0]++;
}
yuka[hozon1][hozon2] = "already";
}
} // End WHILE
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
if (line.isEmpty())
break;
String[] spl = line.split(" ");
int n1 = Integer.parseInt(spl[0]), n2 = Integer.parseInt(spl[1]);
if (n1 == 0 && n2 == 0) {
break;
}
String yuka[][] = new String[n1][n2];
for (int i = 0; i < n1; i++) {
line = br.readLine();
char spl2[] = line.toCharArray();
for (int j = 0; j < n2; j++) {
yuka[i][j] = spl2[j] + "";
}
}
int[] basyo = {0, 0};
while (true) {
String moji = yuka[basyo[0]][basyo[1]];
if (yuka[basyo[0]][basyo[1]].equals(".")) {
System.out.println(basyo[1] + " " + basyo[0]);
break;
}
if (yuka[basyo[0]][basyo[1]].equals("already")) {
System.out.println("LOOP");
break;
}
int hozon1 = basyo[0], hozon2 = basyo[1];
if (yuka[basyo[0]][basyo[1]].equals("<")) {
basyo[1]--;
}
if (yuka[basyo[0]][basyo[1]].equals(">")) {
basyo[1]++;
}
if (yuka[basyo[0]][basyo[1]].equals("^")) {
basyo[0]--;
}
if (yuka[basyo[0]][basyo[1]].equals("v")) {
basyo[0]++;
}
yuka[hozon1][hozon2] = "already";
}
} // End WHILE
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
[["-", 3, 4, 0, 16, 31, 16, 31, 504, 516, 22], ["-", 3, 4, 0, 16, 31, 16, 31, 504, 0, 70], ["-", 0, 16, 31, 16, 31, 504, 71, 504, 0, 73], ["-", 0, 492, 3, 4, 0, 16, 12, 504, 516, 22], ["-", 0, 492, 3, 4, 0, 16, 12, 504, 0, 70], ["-", 3, 4, 0, 16, 12, 504, 71, 504, 0, 73]]
| 3
| 505
| 6
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public char[][] tile;
public int[][] movedTile;
public static void main(String[] args) throws IOException {
BufferedReader bReader =
new BufferedReader(new InputStreamReader(System.in));
String inputedStr;
while (!"0 0".equals(inputedStr = bReader.readLine())) {
boolean loopFlag = true;
String[] editedstr = inputedStr.split(" ");
int X = Integer.parseInt(editedstr[0]);
int Y = Integer.parseInt(editedstr[1]);
char[][] tile = new char[X][Y];
int[][] movedTile = new int[X][Y];
int xcurrentloc = 0;
int ycurrentloc = 0;
for (int i = 0; i < X; i++) {
tile[i] = bReader.readLine().toCharArray();
}
while (movedTile[xcurrentloc][ycurrentloc] != 1) {
if (tile[xcurrentloc][ycurrentloc] == '>') {
movedTile[xcurrentloc][ycurrentloc++] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == '<') {
movedTile[xcurrentloc][ycurrentloc--] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == 'v') {
movedTile[xcurrentloc++][ycurrentloc] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == '^') {
movedTile[xcurrentloc--][ycurrentloc] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == '.') {
loopFlag = false;
break;
} else {
}
}
if (loopFlag) {
System.out.println("LOOP");
loopFlag = true;
} else {
System.out.println(xcurrentloc + " " + ycurrentloc);
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public char[][] tile;
public int[][] movedTile;
public static void main(String[] args) throws IOException {
BufferedReader bReader =
new BufferedReader(new InputStreamReader(System.in));
String inputedStr;
while (!"0 0".equals(inputedStr = bReader.readLine())) {
boolean loopFlag = true;
String[] editedstr = inputedStr.split(" ");
int X = Integer.parseInt(editedstr[0]);
int Y = Integer.parseInt(editedstr[1]);
char[][] tile = new char[X][Y];
int[][] movedTile = new int[X][Y];
int xcurrentloc = 0;
int ycurrentloc = 0;
for (int i = 0; i < X; i++) {
tile[i] = bReader.readLine().toCharArray();
}
while (movedTile[xcurrentloc][ycurrentloc] != 1) {
if (tile[xcurrentloc][ycurrentloc] == '>') {
movedTile[xcurrentloc][ycurrentloc++] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == '<') {
movedTile[xcurrentloc][ycurrentloc--] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == 'v') {
movedTile[xcurrentloc++][ycurrentloc] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == '^') {
movedTile[xcurrentloc--][ycurrentloc] = 1;
} else if (tile[xcurrentloc][ycurrentloc] == '.') {
loopFlag = false;
break;
} else {
}
}
if (loopFlag) {
System.out.println("LOOP");
loopFlag = true;
} else {
System.out.println(ycurrentloc + " " + xcurrentloc);
}
}
}
}
|
[["-", 0, 492, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 492, 3, 4, 0, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22]]
| 3
| 392
| 4
|
#include <stdio.h>
char map[104][104];
int a, b;
int main(void) {
int i, j, x, y;
while (scanf("%d %d", &a, &b), a + b) {
for (i = 0; a - i; i++)
scanf("%s", map[i]);
while (map[x][y] - 46 && map[x][y] - 32) {
i = x;
j = y;
if (map[x][y] == 94)
x--;
if (map[x][y] / 95)
x++;
if (map[x][y] == 60)
y--;
if (map[x][y] == 62)
y++;
map[i][j] = 32;
}
if (map[x][y] == 32)
puts("LOOP");
else
printf("%d %d\n", y, x);
}
return 0;
}
|
#include <stdio.h>
char map[104][104];
int a, b;
int main(void) {
int i, j, x, y;
while (scanf("%d %d", &a, &b), a + b) {
for (i = 0; a - i; i++)
scanf("%s", map[i]);
x = y = 0;
while (map[x][y] - 46 && map[x][y] - 32) {
i = x;
j = y;
if (map[x][y] == 94)
x--;
if (map[x][y] / 95)
x++;
if (map[x][y] == 60)
y--;
if (map[x][y] == 62)
y++;
map[i][j] = 32;
}
if (map[x][y] == 32)
puts("LOOP");
else
printf("%d %d\n", y, x);
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 0
| 215
| 6
|
#include <stdio.h>
int main(void) {
int w, h, i, j, x, y;
char current_tile;
for (;;) {
scanf("%d %d", &h, &w);
if (h == 0 && w == 0)
break;
char tiles[h][w];
int flags[h][w];
for (i = 0; i < h; i++) {
scanf("%s", tiles[i]);
}
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
flags[i][j] = 0;
}
}
x = 0, y = 0;
while (1) {
current_tile = tiles[y][x];
if (current_tile == '>') {
x += 1;
} else if (current_tile == '<') {
x -= 1;
} else if (current_tile == '^') {
y -= 1;
} else if (current_tile == 'v') {
y += 1;
} else if (current_tile == '.') {
printf("%d %d\n", x, y);
break;
}
if (flags[y][x] == 1) {
printf("Loop\n");
break;
} else {
flags[y][x] = 1;
}
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int w, h, i, j, x, y;
char current_tile;
for (;;) {
scanf("%d %d", &h, &w);
if (h == 0 && w == 0)
break;
char tiles[h][w];
int flags[h][w];
for (i = 0; i < h; i++) {
scanf("%s", tiles[i]);
}
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
flags[i][j] = 0;
}
}
x = 0, y = 0;
while (1) {
current_tile = tiles[y][x];
if (current_tile == '>') {
x += 1;
} else if (current_tile == '<') {
x -= 1;
} else if (current_tile == '^') {
y -= 1;
} else if (current_tile == 'v') {
y += 1;
} else if (current_tile == '.') {
printf("%d %d\n", x, y);
break;
}
if (flags[y][x] == 1) {
printf("LOOP\n");
break;
} else {
flags[y][x] = 1;
}
}
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 290
| 2
|
#include <stdio.h>
#define max 101
int h, w;
char map[max + 1][max + 1];
void search(int _h, int _w) {
if (map[_h][_w] == '>') {
map[_h][_w] = '#';
search(_h, _w + 1);
} else if (map[_h][_w] == 'v') {
map[_h][_w] = '#';
search(_h + 1, _w);
} else if (map[_h][_w] == '^') {
map[_h][_w] = '#';
search(_h - 1, _w);
} else if (map[_h][_w] == '<') {
map[_h][_w] = '#';
search(_h, _w - 1);
} else if (map[_h][_w] == '.') {
printf("%d %d\n", _w, _h);
return;
} else if (map[_h][_w] == '#') {
printf("Loop\n");
return;
}
}
int main() {
int i;
for (; scanf("%d %d\n", &h, &w) && (w || h);) {
for (i = 0; i < h; i++) {
fgets(map[i], w + 1, stdin);
scanf("\n");
}
search(0, 0);
}
return 0;
}
|
#include <stdio.h>
#define max 101
int h, w;
char map[max + 1][max + 1];
void search(int _h, int _w) {
if (map[_h][_w] == '>') {
map[_h][_w] = '#';
search(_h, _w + 1);
} else if (map[_h][_w] == 'v') {
map[_h][_w] = '#';
search(_h + 1, _w);
} else if (map[_h][_w] == '^') {
map[_h][_w] = '#';
search(_h - 1, _w);
} else if (map[_h][_w] == '<') {
map[_h][_w] = '#';
search(_h, _w - 1);
} else if (map[_h][_w] == '.') {
printf("%d %d\n", _w, _h);
return;
} else if (map[_h][_w] == '#') {
printf("LOOP\n");
return;
}
}
int main() {
int i;
for (; scanf("%d %d\n", &h, &w) && (w || h);) {
for (i = 0; i < h; i++) {
fgets(map[i], w + 1, stdin);
scanf("\n");
}
search(0, 0);
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 324
| 2
|
#include <stdio.h>
/** Application main entry point. */
int main(int argc, char *argv[]) {
for (;;) {
char map[128][128];
int w, h;
int x, y;
scanf(" %d %d", &w, &h);
if (!(w | h))
break;
for (y = 0; y < h; ++y)
for (x = 0; x < w; ++x) {
scanf(" %c", &map[x][y]);
}
for (x = y = 0;;) {
const int t = map[x][y];
map[x][y] = 'Z';
switch (t) {
case '.':
printf("%d %d\n", x, y);
goto CONTT;
case '>':
++x;
break;
case '<':
--x;
break;
case 'v':
++y;
break;
case '^':
--y;
break;
default:
puts("LOOP");
goto CONTT;
}
}
CONTT:;
}
return (0);
}
|
#include <stdio.h>
/** Application main entry point. */
int main(int argc, char *argv[]) {
for (;;) {
char map[128][128];
int w, h;
int x, y;
scanf(" %d %d", &h, &w);
if (!(w | h))
break;
for (y = 0; y < h; ++y)
for (x = 0; x < w; ++x) {
scanf(" %c", &map[x][y]);
}
for (x = y = 0;;) {
const char t = map[x][y];
map[x][y] = 'Z';
switch (t) {
case '.':
printf("%d %d\n", x, y);
goto CONTT;
case '>':
++x;
break;
case '<':
--x;
break;
case 'v':
++y;
break;
case '^':
--y;
break;
default:
puts("LOOP");
goto CONTT;
}
}
CONTT:;
}
return (0);
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40]]
| 0
| 233
| 6
|
#include <stdio.h>
#define N_MAX 101
int main(void) {
int h, i, j;
char map[N_MAX][N_MAX], used[N_MAX][N_MAX];
while (1) {
for (i = 0; i < N_MAX; i++)
for (j = 0; j < N_MAX; j++)
map[i][j] = '.', used[i][j] = 0;
scanf("%d %*d", &h);
if (h == 0)
return 0;
for (i = 0; i < h; i++)
scanf("%s", map[i]);
i = j = 0;
while (!used[i][j] && map[i][j] != '.') {
used[i][j] = 1;
switch (map[i][j]) {
case '>':
j++;
break;
case '<':
j--;
break;
case '^':
i--;
break;
case 'v':
i++;
break;
}
}
if (used[i][j])
puts("LOOP");
else
printf("%d %d", j, i);
}
}
|
#include <stdio.h>
#define N_MAX 101
int main(void) {
int h, i, j;
char map[N_MAX][N_MAX], used[N_MAX][N_MAX];
while (1) {
for (i = 0; i < N_MAX; i++)
for (j = 0; j < N_MAX; j++)
map[i][j] = '.', used[i][j] = 0;
scanf("%d %*d", &h);
if (h == 0)
return 0;
for (i = 0; i < h; i++)
scanf("%s", map[i]);
i = j = 0;
while (!used[i][j] && map[i][j] != '.') {
used[i][j] = 1;
switch (map[i][j]) {
case '>':
j++;
break;
case '<':
j--;
break;
case '^':
i--;
break;
case 'v':
i++;
break;
}
}
if (used[i][j])
puts("LOOP");
else
printf("%d %d\n", j, i);
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 256
| 1
|
#include <stdio.h>
char map[101][101];
int H, W;
void visit(int i, int j) {
char temp;
temp = map[i][j];
if (temp == ".") {
printf("%d %d\n", j, i);
return;
}
if (temp == '@') {
printf("LOOP\n");
return;
}
map[i][j] = '@';
if (temp == '>') {
visit(i, j + 1);
} else if (temp == '<') {
visit(i, j - 1);
} else if (temp == '^') {
visit(i - 1, j);
} else if (temp == 'v') {
visit(i + 1, j);
}
}
int main() {
char x;
int i, j;
while (1) {
scanf("%d %d", &H, &W);
if (H == 0 && W == 0)
break;
for (i = 0; i < H; i++) {
getchar();
for (j = 0; j < W; j++) {
scanf("%c", &x);
map[i][j] = x;
}
}
visit(0, 0);
}
return 0;
}
|
#include <stdio.h>
char map[101][101];
int H, W;
void visit(int i, int j) {
char temp;
temp = map[i][j];
if (temp == '.') {
printf("%d %d\n", j, i);
return;
}
if (temp == '@') {
printf("LOOP\n");
return;
}
map[i][j] = '@';
if (temp == '>') {
visit(i, j + 1);
} else if (temp == '<') {
visit(i, j - 1);
} else if (temp == '^') {
visit(i - 1, j);
} else if (temp == 'v') {
visit(i + 1, j);
}
}
int main() {
char x;
int i, j;
while (1) {
scanf("%d %d", &H, &W);
if (H == 0 && W == 0)
break;
for (i = 0; i < H; i++) {
getchar();
for (j = 0; j < W; j++) {
scanf("%c", &x);
map[i][j] = x;
}
}
visit(0, 0);
}
return 0;
}
|
[["-", 0, 57, 15, 23, 0, 16, 12, 5, 0, 62], ["+", 0, 57, 15, 23, 0, 16, 12, 103, 0, 104]]
| 0
| 284
| 4
|
#include <iostream>
using namespace std;
string s[100];
bool used[100][100];
int h, w;
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
main() {
while (cin >> h >> w, h) {
for (int i = 0; i < h; i++) {
cin >> s[i];
for (int j = 0; j < w; j++)
used[i][j] = 0;
}
int x = 0, y = 0, f = 0;
while (!used[x][y]) {
used[x][y] = 1;
if (s[x][y] == '.') {
f = 1;
cout << x + 1 << " " << y + 1 << endl;
break;
}
int r = s[x][y] == '>' ? 0 : s[x][y] == '<' ? 2 : s[x][y] == 'v' ? 1 : 3;
x += dx[r], y += dy[r];
}
if (!f)
cout << "LOOP" << endl;
}
}
|
#include <iostream>
using namespace std;
string s[100];
bool used[100][100];
int h, w;
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
main() {
while (cin >> h >> w, h) {
for (int i = 0; i < h; i++) {
cin >> s[i];
for (int j = 0; j < w; j++)
used[i][j] = 0;
}
int x = 0, y = 0, f = 0;
while (!used[x][y]) {
used[x][y] = 1;
if (s[x][y] == '.') {
f = 1;
cout << y << " " << x << endl;
break;
}
int r = s[x][y] == '>' ? 0 : s[x][y] == '<' ? 2 : s[x][y] == 'v' ? 1 : 3;
x += dx[r], y += dy[r];
}
if (!f)
cout << "LOOP" << endl;
}
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 267
| 8
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int h, w;
string ss[100];
bool x[100][100];
int ans1 = 0, ans2 = 0;
bool ans = true;
bool f() {
while (true) {
if (ss[ans1][ans2] == '.')
return true;
else if (!x[ans1][ans2])
return false;
else if (ss[ans1][ans2] == '>') {
x[ans1][ans2] = false;
ans2++;
f();
} else if (ss[ans1][ans2] == '<') {
x[ans1][ans2] = false;
ans2--;
f();
} else if (ss[ans1][ans2] == 'v') {
x[ans1][ans2] = false;
ans1++;
f();
} else {
x[ans1][ans2] = false;
ans1--;
f();
}
}
}
int main() {
while (true) {
scanf("%d%d", &h, &w);
if (h == 0 && w == 0)
return 0;
for (int i = 0; i < h; i++)
cin >> ss[i];
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
x[i][j] = true;
ans1 = 0, ans2 = 0;
ans = true;
if (f()) {
cout << ans1 << " " << ans2 << "\n";
} else
cout << "LOOP"
<< "\n";
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int h, w;
string ss[100];
bool x[100][100];
int ans1 = 0, ans2 = 0;
bool ans = true;
bool f() {
while (true) {
if (ss[ans1][ans2] == '.')
return true;
else if (!x[ans1][ans2])
return false;
else if (ss[ans1][ans2] == '>') {
x[ans1][ans2] = false;
ans2++;
f();
} else if (ss[ans1][ans2] == '<') {
x[ans1][ans2] = false;
ans2--;
f();
} else if (ss[ans1][ans2] == 'v') {
x[ans1][ans2] = false;
ans1++;
f();
} else {
x[ans1][ans2] = false;
ans1--;
f();
}
}
}
int main() {
while (true) {
scanf("%d%d", &h, &w);
if (h == 0 && w == 0)
return 0;
for (int i = 0; i < h; i++)
cin >> ss[i];
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
x[i][j] = true;
ans1 = 0, ans2 = 0;
ans = true;
if (f()) {
cout << ans2 << " " << ans1 << "\n";
} else
cout << "LOOP"
<< "\n";
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 355
| 4
|
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i = m; i < static_cast<int>(n); ++i)
int main() {
int height, width;
std::vector<std::string> tile = {">", "<", "^", "v", "."};
while (std::cin >> height >> width) {
if (height == 0 && width == 0) {
break;
}
std::vector<std::vector<std::string>> table;
REP(i, 0, height) {
table.push_back(std::vector<std::string>());
REP(j, 0, width) {
std::string data;
std::cin >> std::setw(1) >> data;
table[i].push_back(data);
}
}
bool flag = true;
while (flag) {
static int i = 0;
static int j = 0;
if (table[i][j] == tile[0]) {
table[i][j] = ",";
j++;
continue;
} else if (table[i][j] == tile[1]) {
table[i][j] = ",";
j--;
continue;
} else if (table[i][j] == tile[2]) {
table[i][j] = ",";
i--;
continue;
} else if (table[i][j] == tile[3]) {
table[i][j] = ",";
i++;
continue;
} else if (table[i][j] == ",") {
flag = false;
std::cout << "LOOP" << std::endl;
i = j = 0;
} else {
flag = false;
std::cout << i << " " << j << std::endl;
i = j = 0;
}
}
}
return 0;
}
|
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i = m; i < static_cast<int>(n); ++i)
int main() {
int height, width;
std::vector<std::string> tile = {">", "<", "^", "v", "."};
while (std::cin >> height >> width) {
if (height == 0 && width == 0) {
break;
}
std::vector<std::vector<std::string>> table;
REP(i, 0, height) {
table.push_back(std::vector<std::string>());
REP(j, 0, width) {
std::string data;
std::cin >> std::setw(1) >> data;
table[i].push_back(data);
}
}
bool flag = true;
while (flag) {
static int i = 0;
static int j = 0;
if (table[i][j] == tile[0]) {
table[i][j] = ",";
j++;
continue;
} else if (table[i][j] == tile[1]) {
table[i][j] = ",";
j--;
continue;
} else if (table[i][j] == tile[2]) {
table[i][j] = ",";
i--;
continue;
} else if (table[i][j] == tile[3]) {
table[i][j] = ",";
i++;
continue;
} else if (table[i][j] == ",") {
flag = false;
std::cout << "LOOP" << std::endl;
i = j = 0;
} else {
flag = false;
std::cout << j << " " << i << std::endl;
i = j = 0;
}
}
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 401
| 4
|
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
bool calc(vector<vector<char>>, int y, int x);
int resultx;
int resulty;
set<string> passed;
int main() {
while (true) {
int width, height;
cin >> width >> height;
if (width == 0 && height == 0)
break;
vector<vector<char>> field(width, vector<char>(height));
for (int w = 0; w < width; ++w) {
for (int h = 0; h < height; ++h) {
cin >> field[w][h];
}
}
if (calc(field, 0, 0))
cout << resulty << " " << resultx << endl;
}
return 0;
}
bool calc(vector<vector<char>> field, int y, int x) {
stringstream ss;
ss << y << ',' << x;
// cout << ss.str() << endl;
if (passed.find(ss.str()) != passed.end()) {
cout << "LOOP" << endl;
return false;
}
passed.insert(ss.str());
switch (field[x][y]) {
case '>':
return calc(field, y + 1, x);
break;
case '<':
return calc(field, y - 1, x);
break;
case '^':
return calc(field, y, x - 1);
break;
case 'v':
return calc(field, y, x + 1);
break;
case '.':
resultx = x;
resulty = y;
return true;
}
}
|
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
bool calc(vector<vector<char>>, int y, int x);
int resultx;
int resulty;
set<string> passed;
int main() {
while (true) {
passed.clear();
int width, height;
cin >> width >> height;
if (width == 0 && height == 0)
break;
vector<vector<char>> field(width, vector<char>(height));
for (int w = 0; w < width; ++w) {
for (int h = 0; h < height; ++h) {
cin >> field[w][h];
}
}
if (calc(field, 0, 0))
cout << resulty << " " << resultx << endl;
}
return 0;
}
bool calc(vector<vector<char>> field, int y, int x) {
stringstream ss;
ss << y << ',' << x;
// cout << ss.str() << endl;
if (passed.find(ss.str()) != passed.end()) {
cout << "LOOP" << endl;
return false;
}
passed.insert(ss.str());
switch (field[x][y]) {
case '>':
return calc(field, y + 1, x);
break;
case '<':
return calc(field, y - 1, x);
break;
case '^':
return calc(field, y, x - 1);
break;
case 'v':
return calc(field, y, x + 1);
break;
case '.':
resultx = x;
resulty = y;
return true;
}
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 348
| 6
|
// Magical Tiles
#include <iostream>
using namespace std;
int main() {
int H, W;
char Tile[101][101]; //縦横 HW
bool TileIsMoved[101][101];
bool IsLoop, IsEnd;
char Loader[101]; //横行読み
int px, py; //人位置
while (1) {
cin >> H >> W;
if (H == 0 && W == 0)
break;
//初期化
px = 0;
py = 0;
IsLoop = false;
IsEnd = false;
//タイル代入/moved初期化
for (int i = 0; i < H; ++i) {
cin >> Loader;
for (int j = 0; j < W; ++j) {
Tile[i][j] = Loader[j];
TileIsMoved[i][j] = false;
}
}
TileIsMoved[0][0] = true;
//移動
while (1) {
switch (Tile[px][py]) {
case '>':
++px;
break;
case '^':
--py;
break;
case 'v':
++py;
break;
case '<':
--px;
break;
case '.':
IsEnd = true;
break;
}
if (IsEnd)
break;
if (TileIsMoved[px][py]) {
IsLoop = true;
break;
}
TileIsMoved[px][py] = true;
}
//出力
if (IsLoop) {
cout << "LOOP" << endl;
} else {
cout << px << " " << py << endl;
}
}
return 0;
}
|
// Magical Tiles
#include <iostream>
using namespace std;
int main() {
int H, W;
char Tile[101][101]; //縦横 HW
bool TileIsMoved[101][101];
bool IsLoop, IsEnd;
char Loader[101]; //横行読み
int px, py; //人位置
while (1) {
cin >> H >> W;
if (H == 0 && W == 0)
break;
//初期化
px = 0;
py = 0;
IsLoop = false;
IsEnd = false;
//タイル代入/moved初期化
for (int i = 0; i < H; ++i) {
cin >> Loader;
for (int j = 0; j < W; ++j) {
Tile[i][j] = Loader[j];
TileIsMoved[i][j] = false;
}
}
TileIsMoved[0][0] = true;
//移動
while (1) {
switch (Tile[py][px]) {
case '>':
++px;
break;
case '^':
--py;
break;
case 'v':
++py;
break;
case '<':
--px;
break;
case '.':
IsEnd = true;
break;
}
if (IsEnd)
break;
if (TileIsMoved[py][px]) {
IsLoop = true;
break;
}
TileIsMoved[py][px] = true;
}
//出力
if (IsLoop) {
cout << "LOOP" << endl;
} else {
cout << px << " " << py << endl;
}
}
return 0;
}
|
[["-", 15, 339, 51, 69, 28, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 99, 15, 339, 51, 69, 341, 342, 0, 22], ["+", 0, 99, 15, 339, 51, 69, 341, 342, 0, 22], ["-", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22], ["+", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22], ["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
| 1
| 303
| 12
|
#include <iostream>
using namespace std;
int main() {
int w, h, x, y;
char tile[100][100];
bool use[100][100];
bool flg;
while (1) {
cin >> w >> h;
if (w == 0 && h == 0) {
break;
}
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
cin >> tile[x][y];
use[x][y] = false;
}
}
x = 0;
y = 0;
flg = true;
do {
if (use[x][y]) {
cout << "LOOP" << endl;
break;
}
use[x][y] = true;
switch (tile[x][y]) {
case '.':
flg = false;
cout << x << " " << y << endl;
break;
case '>':
x += 1;
break;
case '<':
x -= 1;
break;
case '^':
y -= 1;
break;
case 'v':
y += 1;
break;
}
} while (flg);
}
}
|
#include <iostream>
using namespace std;
int main() {
int w, h, x, y;
char tile[100][100];
bool use[100][100];
bool flg;
while (1) {
cin >> h >> w;
if (w == 0 && h == 0) {
break;
}
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
cin >> tile[x][y];
use[x][y] = false;
}
}
x = 0;
y = 0;
flg = true;
do {
if (use[x][y]) {
cout << "LOOP" << endl;
break;
}
use[x][y] = true;
switch (tile[x][y]) {
case '.':
flg = false;
cout << x << " " << y << endl;
break;
case '>':
x += 1;
break;
case '<':
x -= 1;
break;
case '^':
y -= 1;
break;
case 'v':
y += 1;
break;
}
} while (flg);
}
}
|
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 249
| 4
|
#include <cstring>
#include <iostream>
using namespace std;
char a[1000][1000];
int h, w, loop, cx, cy;
int main() {
while (true) {
cin >> h >> w;
if (!h) {
break;
}
memset(a, ' ', sizeof(a));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> a[i][j];
}
}
cx = 0;
cy = 0;
loop = 0;
while (true) {
if (loop > 10000000) {
cout << "LOOP" << endl;
break;
}
if (a[cy][cx] == '.') {
cout << cx << ' ' << cy << endl;
break;
}
if (a[cy][cx] == '<') {
cx--;
}
if (a[cy][cx] == '>') {
cx++;
}
if (a[cy][cx] == '^') {
cy--;
}
if (a[cy][cx] == 'v') {
cx++;
}
loop++;
}
}
}
|
#include <cstring>
#include <iostream>
using namespace std;
char a[8000][8000];
int h, w, loop, cx, cy;
int main() {
while (true) {
cin >> h >> w;
if (!h) {
break;
}
memset(a, ' ', sizeof(a));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> a[i][j];
}
}
cx = 0;
cy = 0;
loop = 0;
while (true) {
if (loop > 15000000) {
cout << "LOOP" << endl;
break;
}
if (a[cy][cx] == '.') {
cout << cx << ' ' << cy << endl;
break;
}
if (a[cy][cx] == '<') {
cx--;
}
if (a[cy][cx] == '>') {
cx++;
}
if (a[cy][cx] == '^') {
cy--;
}
if (a[cy][cx] == 'v') {
cy++;
}
loop++;
}
}
}
|
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22]]
| 1
| 256
| 8
|
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define CI cin >>
#define CO cout <<
#define E << endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;
string c;
string sA, strB;
vector<vector<char>> map;
vector<int> population;
void input() {
CI W >> H;
map.resize(W);
REP(i, W) { map[i].resize(H); }
REP(i, W) {
REP(j, H) { CI map[i][j]; }
}
}
void proce() {
int posn[2] = {0, 0};
vector<vector<bool>> check(W, vector<bool>(H, false));
while (map[posn[0]][posn[1]] != '.') {
check[posn[0]][posn[1]] = true;
if (map[posn[0]][posn[1]] == '>') {
posn[1]++;
} else {
if (map[posn[0]][posn[1]] == 'v') {
posn[0]++;
} else {
if (map[posn[0]][posn[1]] == '<') {
posn[1]--;
} else {
if (map[posn[0]][posn[1]] == '^') {
posn[0]--;
}
}
}
}
if (check[posn[0]][posn[1]] == true) {
CO "ROOP" E return;
}
}
CO posn[1] << " " << posn[0] E
}
int main(void) {
while (true) {
input();
if (W == 0 && H == 0) {
break;
}
proce();
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define CI cin >>
#define CO cout <<
#define E << endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int A = 0, B = 0, C = 0, K = 0, S = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;
string c;
string sA, strB;
vector<vector<char>> map;
vector<int> population;
void input() {
CI W >> H;
map.resize(W);
REP(i, W) { map[i].resize(H); }
REP(i, W) {
REP(j, H) { CI map[i][j]; }
}
}
void proce() {
int posn[2] = {0, 0};
vector<vector<bool>> check(W, vector<bool>(H, false));
while (map[posn[0]][posn[1]] != '.') {
check[posn[0]][posn[1]] = true;
if (map[posn[0]][posn[1]] == '>') {
posn[1]++;
} else {
if (map[posn[0]][posn[1]] == 'v') {
posn[0]++;
} else {
if (map[posn[0]][posn[1]] == '<') {
posn[1]--;
} else {
if (map[posn[0]][posn[1]] == '^') {
posn[0]--;
}
}
}
}
if (check[posn[0]][posn[1]] == true) {
CO "LOOP" E return;
}
}
CO posn[1] << " " << posn[0] E
}
int main(void) {
while (true) {
input();
if (W == 0 && H == 0) {
break;
}
proce();
}
return 0;
}
|
[["-", 64, 9, 0, 1, 0, 61, 0, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 61, 0, 5, 0, 6]]
| 1
| 566
| 2
|
#include <cstdio>
#include <iostream>
#include <string>
#define MAX_N 105
using namespace std;
int n, h, w;
int area[MAX_N][MAX_N];
string s[MAX_N];
void move(int h, int w) {
if (area[h][w] == 1) {
cout << "LOOP" << endl;
return;
}
area[h][w] = 1;
switch (s[h][w]) {
case '>':
move(h, w + 1);
return;
break;
case '<':
move(h, w - 1);
return;
break;
case 'v':
move(h + 1, w);
return;
break;
case '^':
move(h - 1, w);
return;
break;
case '.':
cout << w << " " << h << endl;
return;
break;
}
return;
}
int main() {
while (1) {
cin >> h >> w;
if (h == 0 && w == 0)
break;
for (int i; i < h; i++) {
for (int j; j < w; j++) {
area[i][j] == 0;
}
}
for (int i = 0; i < h; i++) {
cin >> s[i];
}
move(0, 0);
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
#define MAX_N 105
using namespace std;
int n, h, w;
int area[MAX_N][MAX_N];
string s[MAX_N];
void move(int h, int w) {
if (area[h][w] == 1) {
cout << "LOOP" << endl;
return;
}
area[h][w] = 1;
switch (s[h][w]) {
case '>':
move(h, w + 1);
return;
break;
case '<':
move(h, w - 1);
return;
break;
case 'v':
move(h + 1, w);
return;
break;
case '^':
move(h - 1, w);
return;
break;
case '.':
cout << w << " " << h << endl;
return;
break;
}
return;
}
int main() {
while (1) {
cin >> h >> w;
if (h == 0 && w == 0)
break;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
area[i][j] = 0;
}
}
for (int i = 0; i < h; i++) {
cin >> s[i];
}
move(0, 0);
}
return 0;
}
|
[["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32]]
| 1
| 288
| 6
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int H, W;
while (cin >> H >> W, H + W != 0) {
string tile[H];
for (int i = 0; i < H; i++)
cin >> tile[i];
if (tile[0][0] == '.') {
cout << "0 0" << endl;
continue;
}
int i = 0;
pair<int, int> now = make_pair(0, 0);
while (i != 10001) {
i++;
if (i == 10000)
cout << "LOOP" << endl;
if (tile[now.first][now.second] == '.') {
cout << now.first << " " << now.second << endl;
break;
} else if (tile[now.first][now.second] == '>')
now.second++;
else if (tile[now.first][now.second] == '<')
now.second--;
else if (tile[now.first][now.second] == 'v')
now.first++;
else if (tile[now.first][now.second] == '^')
now.first--;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int H, W;
while (cin >> H >> W, H + W != 0) {
string tile[H];
for (int i = 0; i < H; i++)
cin >> tile[i];
if (tile[0][0] == '.') {
cout << "0 0" << endl;
continue;
}
int i = 0;
pair<int, int> now = make_pair(0, 0);
while (i != 20001) {
i++;
if (i == 20000)
cout << "LOOP" << endl;
if (tile[now.first][now.second] == '.') {
cout << now.second << " " << now.first << endl;
break;
} else if (tile[now.first][now.second] == '>')
now.second++;
else if (tile[now.first][now.second] == '<')
now.second--;
else if (tile[now.first][now.second] == 'v')
now.first++;
else if (tile[now.first][now.second] == '^')
now.first--;
}
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["+", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["-", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["+", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120]]
| 1
| 268
| 8
|
#include <iostream>
#include <string>
using namespace std;
struct point {
char c;
int count;
};
void move(point area[100][100], int &i, int &j) {
area[i][j].count = 0;
if (area[i][j].c == '>') {
j++;
} else if (area[i][j].c == '<') {
j--;
} else if (area[i][j].c == 'v') {
i++;
} else if (area[i][j].c == '^') {
i--;
}
}
int main() {
int h, w;
string s;
point area[100][100];
while (cin >> h >> w) {
if (h == 0 && w == 0)
break;
for (int i = 0; i < h; i++) {
cin >> s;
for (int j = 0; j < s.size(); j++) {
area[i][j].c = s[j];
area[i][j].count = 1;
}
}
int i = 0, j = 0;
while ((area[i][j].c != '.') && (area[i][j].count = 0)) {
move(area, i, j);
}
if (area[i][j].c == '.')
cout << j << " " << i << endl;
else
cout << "LOOP" << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
struct point {
char c;
int count;
};
void move(point area[100][100], int &i, int &j) {
area[i][j].count = 0;
if (area[i][j].c == '>') {
j++;
} else if (area[i][j].c == '<') {
j--;
} else if (area[i][j].c == 'v') {
i++;
} else if (area[i][j].c == '^') {
i--;
}
}
int main() {
int h, w;
string s;
point area[100][100];
while (cin >> h >> w) {
if (h == 0 && w == 0)
break;
for (int i = 0; i < h; i++) {
cin >> s;
for (int j = 0; j < s.size(); j++) {
area[i][j].c = s[j];
area[i][j].count = 1;
}
}
int i = 0, j = 0;
while ((area[i][j].c != '.') && (area[i][j].count == 1)) {
move(area, i, j);
}
if (area[i][j].c == '.')
cout << j << " " << i << endl;
else
cout << "LOOP" << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 23, 0, 42, 0, 32], ["-", 15, 339, 51, 16, 12, 23, 0, 42, 0, 13], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 60], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 12, 13]]
| 1
| 344
| 4
|
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
int w, h;
int dx[128] = {0};
int dy[128] = {0};
dx['<'] = -1;
dx['>'] = 1;
dy['^'] = -1;
dy['v'] = 1;
while (cin >> w >> h, w) {
char data[128][128] = {0};
rep(i, h) rep(j, w) cin >> data[i][j];
int x = 0, y = 0, f = 0;
while (data[y][x] != '.') {
char c = data[y][x];
if (c == '-') {
f = 1;
break;
} else
data[y][x] = '-';
x += dx[c], y += dy[c];
}
if (f)
cout << "LOOP" << endl;
else
cout << x << " " << y << endl;
}
}
|
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
int w, h;
int dx[128] = {0};
int dy[128] = {0};
dx['<'] = -1;
dx['>'] = 1;
dy['^'] = -1;
dy['v'] = 1;
while (cin >> h >> w, w) {
char data[128][128] = {0};
rep(i, h) rep(j, w) cin >> data[i][j];
int x = 0, y = 0, f = 0;
while (data[y][x] != '.') {
char c = data[y][x];
if (c == '-') {
f = 1;
break;
} else
data[y][x] = '-';
x += dx[c], y += dy[c];
}
if (f)
cout << "LOOP" << endl;
else
cout << x << " " << y << endl;
}
}
|
[["-", 15, 339, 51, 34, 31, 16, 31, 16, 12, 22], ["-", 0, 52, 15, 339, 51, 34, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 34, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 34, 31, 16, 12, 22]]
| 1
| 242
| 4
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
while (scanf("%d%d", &h, &w)) {
if (h == 0 && w == 0)
break;
vector<string> map;
for (int i = 0; i < h; i++) {
string in;
cin >> in;
map.push_back(in);
}
vector<vector<int>> went;
for (int i = 0; i < h; i++) {
vector<int> num(w, 0);
went.push_back(num);
}
int ni = 0, nj = 0;
bool flag = false;
while (map[ni][nj] != '.') {
if (went[ni][nj] == 1) {
flag = true;
break;
}
went[ni][nj]++;
if (map[ni][nj] == '>') {
nj++;
} else if (map[ni][nj] == '<') {
nj--;
} else if (map[ni][nj] == '^') {
ni--;
} else if (map[ni][nj] == 'v') {
ni++;
}
}
if (flag)
printf("LOOP\n");
else
printf("%d %d\n", ni, nj);
}
}
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
while (scanf("%d%d", &h, &w)) {
if (h == 0 && w == 0)
break;
vector<string> map;
for (int i = 0; i < h; i++) {
string in;
cin >> in;
map.push_back(in);
}
vector<vector<int>> went;
for (int i = 0; i < h; i++) {
vector<int> num(w, 0);
went.push_back(num);
}
int ni = 0, nj = 0;
bool flag = false;
while (map[ni][nj] != '.') {
if (went[ni][nj] == 1) {
flag = true;
break;
}
went[ni][nj]++;
if (map[ni][nj] == '>') {
nj++;
} else if (map[ni][nj] == '<') {
nj--;
} else if (map[ni][nj] == '^') {
ni--;
} else if (map[ni][nj] == 'v') {
ni++;
}
}
if (flag)
printf("LOOP\n");
else
printf("%d %d\n", nj, ni);
}
}
|
[["-", 75, 76, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 75, 76, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 75, 76, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 75, 76, 0, 1, 0, 2, 3, 4, 0, 22]]
| 1
| 294
| 4
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int W, H;
while (cin >> W >> H) {
if ((W | H) == 0)
break;
vector<string> tile(H);
for (int i = 0; i < H; ++i)
cin >> tile[i];
int x = 0, y = 0;
bool loop = false;
vector<vector<int>> visited(H, vector<int>(W, 0));
while (tile[y][x] != '.') {
if (visited[y][x]) {
loop = true;
break;
}
visited[y][x] = 1;
if (tile[y][x] == '>')
++x;
else if (tile[y][x] == '<')
--x;
else if (tile[y][x] == 'v')
++y;
else if (tile[y][x] == '^')
--y;
}
if (loop)
cout << "LOOP" << endl;
else
cout << x << " " << y << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int W, H;
while (cin >> H >> W) {
if ((W | H) == 0)
break;
vector<string> tile(H);
for (int i = 0; i < H; ++i)
cin >> tile[i];
int x = 0, y = 0;
bool loop = false;
vector<vector<int>> visited(H, vector<int>(W, 0));
while (tile[y][x] != '.') {
if (visited[y][x]) {
loop = true;
break;
}
visited[y][x] = 1;
if (tile[y][x] == '>')
++x;
else if (tile[y][x] == '<')
--x;
else if (tile[y][x] == 'v')
++y;
else if (tile[y][x] == '^')
--y;
}
if (loop)
cout << "LOOP" << endl;
else
cout << x << " " << y << endl;
}
return 0;
}
|
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
| 1
| 252
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define foreach(itr, c) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
int H, W;
char field[110][110];
map<char, int> dx;
map<char, int> dy;
void make() {
dx['^'] = 0;
dy['^'] = -1;
dx['v'] = 0;
dy['v'] = 1;
dx['>'] = 1;
dy['>'] = 0;
dx['<'] = -1;
dy['<'] = 0;
}
pair<int, int> func(int i, int j) {
if (field[i][j] == '.')
return make_pair(i, j);
int cnt = 0;
while (1) {
if (i < 0 || j < 0 || i >= H || j >= W)
continue;
cnt++;
i += dy[field[i][j]];
j += dx[field[i][j]];
if (field[i][j] == '.')
return make_pair(i, j);
if (cnt > 10000)
break;
}
return make_pair(-1, -1);
}
int main() {
int i, j, k;
make();
for (; ~scanf("%d %d", &H, &W);) {
if (H == 0 && W == 0)
break;
rep(i, H) scanf("%s", &field[i]);
pair<int, int> res = func(0, 0), out(-1, -1);
if (res == out)
puts("loop");
else
printf("%d %d\n", res.second, res.first);
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for ((i) = 0; (i) < (int)(n); (i)++)
#define foreach(itr, c) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
int H, W;
char field[110][110];
map<char, int> dx;
map<char, int> dy;
void make() {
dx['^'] = 0;
dy['^'] = -1;
dx['v'] = 0;
dy['v'] = 1;
dx['>'] = 1;
dy['>'] = 0;
dx['<'] = -1;
dy['<'] = 0;
}
pair<int, int> func(int i, int j) {
if (field[i][j] == '.')
return make_pair(i, j);
int cnt = 0;
while (1) {
if (i < 0 || j < 0 || i >= H || j >= W)
continue;
cnt++;
i += dy[field[i][j]];
j += dx[field[i][j]];
if (field[i][j] == '.')
return make_pair(i, j);
if (cnt > 10000)
break;
}
return make_pair(-1, -1);
}
int main() {
int i, j, k;
make();
for (; ~scanf("%d %d", &H, &W);) {
if (H == 0 && W == 0)
break;
rep(i, H) scanf("%s", &field[i]);
pair<int, int> res = func(0, 0), out(-1, -1);
if (res == out)
puts("LOOP");
else
printf("%d %d\n", res.second, res.first);
}
return 0;
}
|
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 417
| 2
|
// 51
#include <iostream>
using namespace std;
int main() {
for (int W, H; cin >> W >> H, W | H;) {
char g[100][100];
for (int y = 0; y < H; y++) {
for (int x = 0; x < W; x++) {
cin >> g[y][x];
}
}
int y = 0, x = 0;
while (g[y][x] != '.' && g[y][x] != '\0') {
int ny = y + (g[y][x] == 'v') - (g[y][x] == '^');
int nx = x + (g[y][x] == '>') - (g[y][x] == '<');
g[y][x] = '\0';
y = ny;
x = nx;
}
if (g[y][x]) {
cout << x << ' ' << y << endl;
} else {
cout << "LOOP" << endl;
}
}
return 0;
}
|
// 51
#include <iostream>
using namespace std;
int main() {
for (int W, H; cin >> H >> W, W | H;) {
char g[100][100];
for (int y = 0; y < H; y++) {
for (int x = 0; x < W; x++) {
cin >> g[y][x];
}
}
int y = 0, x = 0;
while (g[y][x] != '.' && g[y][x] != '\0') {
int ny = y + (g[y][x] == 'v') - (g[y][x] == '^');
int nx = x + (g[y][x] == '>') - (g[y][x] == '<');
g[y][x] = '\0';
y = ny;
x = nx;
}
if (g[y][x]) {
cout << x << ' ' << y << endl;
} else {
cout << "LOOP" << endl;
}
}
return 0;
}
|
[["-", 0, 7, 15, 34, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 7, 15, 34, 31, 16, 17, 152], ["+", 8, 9, 0, 7, 15, 34, 31, 16, 17, 152], ["+", 8, 9, 0, 7, 15, 34, 31, 16, 12, 22]]
| 1
| 245
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
int H, W;
int main(void) {
while (cin >> H >> W, H && W) {
char room[101][102] = {};
bool fd[101][101] = {};
for (int i = 0; i < H; i++)
cin >> room[i];
int x = 0, y = 0;
while (room[y][x] != '.' && !fd[y][x]) {
fd[y][x] = true;
switch (room[y][x]) {
case '>':
x++;
break;
case '^':
y--;
break;
case '<':
x--;
break;
case 'v':
y++;
break;
}
}
if (room[x][y] == '.')
cout << x << ' ' << y << endl;
else
cout << "LOOP" << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int H, W;
int main(void) {
while (cin >> H >> W, H && W) {
char room[101][102] = {};
bool fd[101][101] = {};
for (int i = 0; i < H; i++)
cin >> room[i];
int x = 0, y = 0;
while (room[y][x] != '.' && !fd[y][x]) {
fd[y][x] = true;
switch (room[y][x]) {
case '>':
x++;
break;
case '^':
y--;
break;
case '<':
x--;
break;
case 'v':
y++;
break;
}
}
if (room[y][x] == '.')
cout << x << ' ' << y << endl;
else
cout << "LOOP" << endl;
}
return 0;
}
|
[["-", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22]]
| 1
| 213
| 4
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int W, H;
char fie[102][102];
int cost[102][102];
char df[] = {'>', 'v', '<', '^'};
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
while (1) {
cin >> W >> H;
memset(fie, -1, sizeof(fie));
memset(cost, 0, sizeof(cost));
if (W == 0 && H == 0)
break;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> fie[j][i];
}
}
int x = 0, y = 0;
bool f = false;
cost[x][y] = 1;
while (fie[x][y] != '.') {
for (int i = 0; i < 4; i++) {
if (fie[x][y] == df[i]) {
x += dx[i];
y += dy[i];
}
}
if (cost[x][y]) {
f = true;
break;
}
cost[x][y] = 1;
}
if (!f)
printf("%d %d\n", x, y);
else
puts("LOOP");
}
}
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int W, H;
char fie[102][102];
int cost[102][102];
char df[] = {'>', 'v', '<', '^'};
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
while (1) {
cin >> H >> W;
memset(fie, -1, sizeof(fie));
memset(cost, 0, sizeof(cost));
if (W == 0 && H == 0)
break;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> fie[j][i];
}
}
int x = 0, y = 0;
bool f = false;
cost[x][y] = 1;
while (fie[x][y] != '.') {
for (int i = 0; i < 4; i++) {
if (fie[x][y] == df[i]) {
x += dx[i];
y += dy[i];
}
}
if (cost[x][y]) {
f = true;
break;
}
cost[x][y] = 1;
}
if (!f)
printf("%d %d\n", x, y);
else
puts("LOOP");
}
}
|
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 326
| 4
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const char arrow[] = {'>', '<', 'v', '^'};
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int main() {
int H, W;
while (cin >> H >> W, H + W) {
vector<string> tile(101);
bool visit[101][101];
for (int i = 0; i < H; i++) {
cin >> tile[i];
}
int x = 0, y = 0;
while (visit[y][x] != true) {
visit[y][x] = true;
for (int i = 0; i < 4; i++) {
if (tile[y][x] == arrow[i]) {
x += dx[i];
y += dy[i];
break;
}
}
}
if (tile[y][x] == '.') {
cout << x << ' ' << y << endl;
} else {
cout << "LOOP" << endl;
}
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const char arrow[] = {'>', '<', 'v', '^'};
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int main() {
int H, W;
while (cin >> H >> W, H + W) {
vector<string> tile(H);
bool visit[101][101] = {false};
for (int i = 0; i < H; i++) {
cin >> tile[i];
}
int x = 0, y = 0;
while (visit[y][x] != true) {
visit[y][x] = true;
for (int i = 0; i < 4; i++) {
if (tile[y][x] == arrow[i]) {
x += dx[i];
y += dy[i];
break;
}
}
}
if (tile[y][x] == '.') {
cout << x << ' ' << y << endl;
} else {
cout << "LOOP" << endl;
}
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 147], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
| 1
| 258
| 6
|
#include <cstring>
#include <iostream>
using namespace std;
int w, h;
char map[102][102];
bool closed[102][102];
void rec(int x, int y) {
if (closed[y][x]) {
cout << "LOOP" << endl;
return;
}
closed[y][x] = true;
if (map[y][x] == '>')
rec(x + 1, y);
else if (map[y][x] == 'v')
rec(x, y + 1);
else if (map[y][x] == '<')
rec(x - 1, y);
else if (map[y][x] == '^')
rec(x, y - 1);
else {
cout << x << " " << y << endl;
}
}
void solve() { rec(0, 0); }
int main() {
while (cin >> h >> w, w || h) {
memset(map, 0, sizeof(map));
for (int i = 0; i < h; i++)
cin >> map[i];
solve();
}
return 0;
}
|
#include <cstring>
#include <iostream>
using namespace std;
int w, h;
char map[102][102];
bool closed[102][102];
void rec(int x, int y) {
if (closed[y][x]) {
cout << "LOOP" << endl;
return;
}
closed[y][x] = true;
if (map[y][x] == '>')
rec(x + 1, y);
else if (map[y][x] == 'v')
rec(x, y + 1);
else if (map[y][x] == '<')
rec(x - 1, y);
else if (map[y][x] == '^')
rec(x, y - 1);
else {
cout << x << " " << y << endl;
}
}
void solve() { rec(0, 0); }
int main() {
while (cin >> h >> w, w || h) {
memset(closed, 0, sizeof(closed));
for (int i = 0; i < h; i++)
cin >> map[i];
solve();
}
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 2, 3, 4, 0, 105, 51, 23, 0, 22], ["+", 0, 2, 3, 4, 0, 105, 51, 23, 0, 22]]
| 1
| 257
| 4
|
#include <iostream>
using namespace std;
int main() {
int W, H;
while (cin >> W >> H && W + H != 0) {
char room[101][101];
for (int w = 0; w != W; ++w) {
cin >> room[w];
}
int x = 0, y = 0;
bool loop = false;
while (room[x][y] != '.') {
if (room[x][y] == '>') {
room[x][y] = 'x';
y++;
} else if (room[x][y] == '<') {
room[x][y] = 'x';
y--;
} else if (room[x][y] == '^') {
room[x][y] = 'x';
x--;
} else if (room[x][y] == 'v') {
room[x][y] = 'x';
x++;
} else if (room[x][y] == 'x') {
loop = true;
break;
}
}
if (loop) {
cout << "LOOP" << endl;
} else {
cout << x << " " << y << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int W, H;
while (cin >> W >> H && W + H != 0) {
char room[101][101];
for (int w = 0; w != W; ++w) {
cin >> room[w];
}
int x = 0, y = 0;
bool loop = false;
while (room[x][y] != '.') {
if (room[x][y] == '>') {
room[x][y] = 'x';
y++;
} else if (room[x][y] == '<') {
room[x][y] = 'x';
y--;
} else if (room[x][y] == '^') {
room[x][y] = 'x';
x--;
} else if (room[x][y] == 'v') {
room[x][y] = 'x';
x++;
} else if (room[x][y] == 'x') {
loop = true;
break;
}
}
if (loop) {
cout << "LOOP" << endl;
} else {
cout << y << " " << x << endl;
}
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 277
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
char G[100][100];
bool visited[100][100];
int W, H;
string str;
while (cin >> W >> H) {
if (W == 0 && H == 0)
break;
for (int i = 0; i < H; i++) {
cin >> str;
for (int j = 0; j < W; j++) {
G[i][j] = str[j];
visited[i][j] = false;
}
}
int x = 0, y = 0;
while (1) {
if (visited[y][x]) {
cout << "LOOP" << endl;
break;
}
visited[y][x] = true;
if (G[y][x] == '>')
x++;
else if (G[y][x] == 'v')
y++;
else if (G[y][x] == '^')
y--;
else if (G[y][x] == '<')
x--;
else if (G[y][x] == '.') {
cout << x << " " << y << endl;
break;
}
}
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
char G[200][200];
bool visited[200][200];
int W, H;
string str;
while (cin >> H >> W) {
if (W == 0 && H == 0)
break;
for (int i = 0; i < H; i++) {
cin >> str;
for (int j = 0; j < W; j++) {
G[i][j] = str[j];
visited[i][j] = false;
}
}
int x = 0, y = 0;
while (1) {
if (visited[y][x]) {
cout << "LOOP" << endl;
break;
}
visited[y][x] = true;
if (G[y][x] == '>')
x++;
else if (G[y][x] == 'v')
y++;
else if (G[y][x] == '^')
y--;
else if (G[y][x] == '<')
x--;
else if (G[y][x] == '.') {
cout << x << " " << y << endl;
break;
}
}
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
| 1
| 274
| 12
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int w, h;
string a[102];
while (cin >> w >> h, w) {
for (int i = 0; i < 102; i++) {
a[i] = "";
}
for (int i = 0; i < w; i++) {
cin >> a[i];
}
int x = 0, y = 0;
while (true) {
if (a[x][y] == '.') {
cout << x << ' ' << y << endl;
break;
} else if (a[x][y] == 'o') {
cout << "LOOP" << endl;
break;
} else if (a[x][y] == '>') {
a[x][y] = 'o';
y++;
} else if (a[x][y] == '<') {
a[x][y] = 'o';
y--;
} else if (a[x][y] == '^') {
a[x][y] = 'o';
x--;
} else if (a[x][y] == 'v') {
a[x][y] = 'o';
x++;
}
}
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int w, h;
string a[102];
while (cin >> w >> h, w) {
for (int i = 0; i < 102; i++) {
a[i] = "";
}
for (int i = 0; i < w; i++) {
cin >> a[i];
}
int x = 0, y = 0;
while (true) {
if (a[x][y] == '.') {
cout << y << ' ' << x << endl;
break;
} else if (a[x][y] == 'o') {
cout << "LOOP" << endl;
break;
} else if (a[x][y] == '>') {
a[x][y] = 'o';
y++;
} else if (a[x][y] == '<') {
a[x][y] = 'o';
y--;
} else if (a[x][y] == '^') {
a[x][y] = 'o';
x--;
} else if (a[x][y] == 'v') {
a[x][y] = 'o';
x++;
}
}
}
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 284
| 4
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int n;
cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
getline(cin, s);
while (1) {
if (s.find("Hoshina") == string::npos)
break;
s.replace(s.find("Hoshina"), 7, "Hashino");
}
cout << s << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int n;
cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
getline(cin, s);
while (1) {
if (s.find("Hoshino") == string::npos)
break;
s.replace(s.find("Hoshino"), 7, "Hoshina");
}
cout << s << endl;
}
}
|
[["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 3, 4, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 3, 4, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 104
| 6
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int n;
int c_pos;
cin >> n;
cin.ignore();
while (n--) {
getline(cin, s);
while ((c_pos = s.find("Hoshino")) != string::npos) {
s.replace(c_pos, 7, "Hashina");
}
cout << s << endl;
}
}
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int n;
int c_pos;
cin >> n;
cin.ignore();
while (n--) {
getline(cin, s);
while ((c_pos = s.find("Hoshino")) != string::npos) {
s.replace(c_pos, 7, "Hoshina");
}
cout << s << endl;
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 89
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.