답안 #883383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883383 2023-12-05T08:47:41 Z catlover Ruka (COI15_ruka) C++14
9 / 100
2000 ms 2860 KB
#include <bits/stdc++.h>

#define int long long

#define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int maxN = 1e6;

typedef pair<int, int> pii;

int N, M;
pii p[maxN+5];

void read_input()
{
  cin >> N;
  FOR(i, 1, N) cin >> p[i].fi >> p[i].se;
}

namespace sub1
{
  bool checkX(pii bf, pii aft)
  {
    return (bf.fi * aft.fi <= 0);
  }

  bool checkY(pii bf, pii aft)
  {
    return (bf.se * aft.se <= 0);
  }

  void solve()
  {
    int cur = 1;
    p[0] = mp(1, 1);
    cin >> M;
    while(M --> 0)
    {
      char type;  cin >> type;
      if(type == 'C')
      {
        int nx, ny; cin >> nx >> ny;
        p[cur] = mp(nx, ny);
      }
      else if(type == 'Q')
      {
        int ans = 0;
        pii pn = mp(1, 1), pw;
        FOR(i, 1, N)
        {
          pw = mp(pn.fi + p[i].fi, pn.se + p[i].se);
          if(checkX(pw, pn)) ++ans;
          if(checkY(pw, pn)) ++ans;
          pn = pw;
        }
        cout << ans << '\n';
      }
      else if(type == 'B')
      {
        if(cur == 1) continue;
        --cur;
      }
      else
      {
        if(cur == N) continue;
        ++cur;
      }
    }
  }
}

void solve()
{
  sub1::solve();
}

int32_t main()
{
  cin.tie(0)->sync_with_stdio(0);

  file("SIMULATION");

  read_input();
  solve();

  return 0;
}

Compilation message

ruka.cpp: In function 'int32_t main()':
ruka.cpp:5:56: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
      |                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ruka.cpp:88:3: note: in expansion of macro 'file'
   88 |   file("SIMULATION");
      |   ^~~~
ruka.cpp:5:89: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
      |                                                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ruka.cpp:88:3: note: in expansion of macro 'file'
   88 |   file("SIMULATION");
      |   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 2036 ms 2860 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 2036 ms 2860 KB Time limit exceeded
6 Halted 0 ms 0 KB -