#include "Anna.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
}
void Anna(int n, vector<char> s){
for(int i = 0; i < n; i++){
if(s[i] == 'X') Send(0), Send(0);
else if(s[i] == 'Y') Send(0), Send(1);
else Send(1);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
}
void Bruno(int n, int m, vector<int> A){
str s = "";
for(int i = 0; i < m; i++){
if(A[i] == 0){
if(A[i+1] == 0) s+="X";
else s+="Y";
i++;
}
else s+="Z";
}
vector<int> lastX(n, -1), firstZ(n, -1);
for(int i = 0; i < n; i++){
if(i != 0) lastX[i] = lastX[i-1];
if(s[i] == 'X') lastX[i] = i;
}
for(int i = n-1; i >= 0; i--){
if(i != n-1) firstZ[i] = firstZ[i+1];
if(s[i] == 'Z') firstZ[i] = i;
}
vector<array<int, 3>> sth;
for(int i = 0; i < n; i++){
if(s[i] != 'Y') continue;
if(lastX[i] == -1 || firstZ[i] == -1) continue;
sth.pb({lastX[i], i, firstZ[i]});
}
sort(sth.begin(), sth.end(), [](array<int, 3> a, array<int, 3> b){
return a[2]-a[0] < b[2]-b[0];
});
set<int> ss;
for(int i = 0; i < n; i++) ss.insert(i);
for(auto [x, y, z]: sth){
auto itx = ss.find(x);
auto ity = ss.find(y);
auto itz = ss.find(z);
if(itx == ss.end() || ity == ss.end() || itz == ss.end()) continue;
itx++;
while(itx != itz){
if(itx == ity){
itx++;
continue;
}
Remove(*itx);
itx = ss.erase(itx);
}
Remove(*ity);
ss.erase(ity);
}
while(!ss.empty()){
Remove(*ss.begin());
ss.erase(ss.begin());
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
520 KB |
Output is correct |
4 |
Correct |
0 ms |
520 KB |
Output is correct |
5 |
Incorrect |
1 ms |
580 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
123 ms |
10732 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |