답안 #263964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263964 2020-08-14T04:33:37 Z 반딧불(#5094) 전차 (CEOI13_tram) C++17
실패
1000 ms 512 KB
#include <bits/stdc++.h>
#define SQR(x) ((x)*(x))

using namespace std;

typedef long long ll;

int n, m, p;
int x[1502], y[1502];
int idx[1502];
bool riding[1502];
bool occupied[1502][3];

int main(){
    scanf("%d %d", &n, &m);
    for(int q=1; q<=m; q++){
        char c;
        scanf(" %c", &c);
        if(c == 'E'){
            ll dist = 0;
            p++;
            idx[q] = p;
            for(int i=1; i<=n; i++) for(int j=1; j<=2; j++){
                if(occupied[i][j]) continue;
                int minDist = 1e9;
                for(int x=1; x<=n; x++) for(int y=1; y<=2; y++){
                    if(occupied[x][y]) minDist = min(minDist, SQR(i-x) + SQR(j-y));
                }
                if(minDist > dist){
                    dist = minDist;
                    x[p] = i, y[p] = j;
                }
            }
            occupied[x[p]][y[p]] = 1;
        }
        else{
            int p;
            scanf("%d", &p);
            occupied[x[idx[p]]][y[idx[p]]] = 0;
        }
    }
    for(int i=1; i<=p; i++){
        printf("%d %d\n", x[i], y[i]);
    }
}

Compilation message

tram.cpp: In function 'int main()':
tram.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tram.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
tram.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |             scanf("%d", &p);
      |             ~~~~~^~~~~~~~~~