| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1363727 | Aviansh | Naval battle (CEOI24_battle) | C++20 | 251 ms | 36344 KiB |
#include <bits/stdc++.h>
using namespace std;
struct ship{
int x;
int y;
int i;
char c;
};
bool comp(const ship &a, const ship &b){
return a.x<b.x;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
ship arr[n];
for(int i = 0;i<n;i++){
cin >> arr[i].x;
cin >> arr[i].y;
cin >> arr[i].c;
arr[i].i=i;
}
//assume only S and E
map<int,vector<ship>>groups;
set<int>pos;
for(int i = 0;i<n;i++){
groups[arr[i].x+arr[i].y].push_back(arr[i]);
pos.insert(arr[i].x+arr[i].y);
}
for(int i : pos){
sort(groups[i].begin(),groups[i].end(),comp);
}
bool des[n];
fill(des,des+n,0);
for(int g : pos){
int cnt = 0;
for(int i = 0;i<groups[g].size();i++){
if(groups[g][i].c=='E'){
cnt++;
}
else{
if(cnt){
des[groups[g][i].i]=1;
cnt--;
}
}
}
cnt=0;
for(int i = groups[g].size()-1;i>=0;i--){
if(groups[g][i].c=='S'){
cnt++;
}
else{
if(cnt){
des[groups[g][i].i]=1;
cnt--;
}
}
}
}
for(int i = 0;i<n;i++){
if(!des[i]){
cout << i+1 << "\n";
}
}
return 0;
}
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
