답안 #70616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70616 2018-08-23T07:39:11 Z octopuses Alternating Current (BOI18_alternating) C++17
0 / 100
3000 ms 4768 KB
//Giorgi Kldiashvili
#include <bits/stdc++.h>

#define ll long long


using namespace std;

const int N = 100020;

int n, m;

inline int dis(int x, int y)
{
  if(y < x)
    return n + y - x + 1;
  return y - x + 1;
}

vector < pair < int, int > > A[N];
int answer[N], S[N][2];

int main()
{
  scanf("%d %d", &n, &m);
  for(int i = 1; i <= m; ++ i)
  {
    int x, y;
    scanf("%d %d", &x, &y);
    A[x - 1].push_back(make_pair(dis(x, y), i));
  }
  for(int i = 0; i < n; ++ i)
  {
    for(int j = 0; j < A[i].size(); ++ j)
    {
      int x = A[i][j].first;
      int c = 0;
      for(int k = 0; k < n; ++ k)
      {
        int now = (i + k) % n;
        if(S[now][0] == 0)
        {
          c = 0;
          break;
        }
        if(S[now][1] == 0)
        {
          c = 1;
          break;
        }
      }
      answer[A[i][j].second] = c;
      for(int k = 0; k < x; ++ k)
        S[(i + k) % n][c] = 1;
    }
  }
  for(int i = 0; i < n; ++ i)
    if(S[i][0] == 0 || S[i][1] == 0)
      return printf("impossible"), 0;
  for(int i = 1; i <= m; ++ i)
    printf("%d", answer[i]);
}

Compilation message

alternating.cpp: In function 'int main()':
alternating.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0; j < A[i].size(); ++ j)
                    ~~^~~~~~~~~~~~~
alternating.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
alternating.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2716 KB Output is correct
4 Correct 6 ms 2900 KB Output is correct
5 Incorrect 5 ms 2900 KB 'impossible' claimed, but there is a solution
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2716 KB Output is correct
4 Correct 6 ms 2900 KB Output is correct
5 Incorrect 5 ms 2900 KB 'impossible' claimed, but there is a solution
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2716 KB Output is correct
4 Correct 6 ms 2900 KB Output is correct
5 Incorrect 5 ms 2900 KB 'impossible' claimed, but there is a solution
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3044 ms 4768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2716 KB Output is correct
4 Correct 6 ms 2900 KB Output is correct
5 Incorrect 5 ms 2900 KB 'impossible' claimed, but there is a solution
6 Halted 0 ms 0 KB -