QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#325183 | #5581. Champernowne Count | WonchanKim | TL | 0ms | 0kb | C++14 | 1.6kb | 2024-02-11 05:30:44 | 2024-02-11 05:30:44 |
answer
#include<bits/stdc++.h>
using namespace std;
int nearest(int x, int y,vector<pair<int,int>> pos){
int d = 1000;
for(int i = 0; i < pos.size(); i++){
if ((abs(x - pos[i].first) + abs(y - pos[i].second)) < d)
d = abs(x - pos[i].first) + abs(y - pos[i].second);
}
return d;
}
void hit(int x, int y,vector<pair<int,int>>& pos) {
for (int i = 0; i < pos.size(); i++) {
if (pos[i].first == x && pos[i].second == y)
pos.erase(pos.begin() + i);
}
}
bool find(int x, int y,const vector<pair<int,int>>& pos) {
for (int i = 0; i < pos.size(); i++) {
if (pos[i].first == x && pos[i].second == y)
return true;
}
return false;
}
int main() {
int s;
string t;
int x, y;
vector<pair<int,int>> pos;
cin >> s;
while (pos.size() < 4) {
s = s + floor(s/13) + 15;
int z = s % 100;
x = z / 10, y = z % 10;
if (!find(x,y, pos)) {
pos.emplace_back(make_pair(x,y));
}
}
int user_score = 0;
while (pos.size() > 0) {
cin >> t;
x = t[0] - '0';
y = t[1] - '0';
if(find(x, y, pos)){
hit(x, y, pos);
cout << "You hit a wumpus!" << endl;
if (pos.size() != 0)
cout << nearest(x, y, pos) << endl;
}
else {
cout << nearest(x,y,pos) << endl;
}
user_score ++;
}
cout << "Your score is " << user_score << " moves." ;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
4 2
output:
53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 ...