답안 #87054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87054 2018-11-29T09:54:10 Z abil 돌 무게 재기 (IZhO11_stones) C++14
0 / 100
1000 ms 1120 KB
/**
   Solution by Abil
**/
#include <bits/stdc++.h>

using namespace std;

vector<int > v1,v2;
vector<int > :: iterator it;

int fun(int qw){
  int f = 1,in = 0;
  for(int i = 0;i < v1.size(); i++){
    while(in < v2.size() && v2[in] < v1[i]){
      in++;
    }
    if(in >= v2.size()){
      f = 0;
      break;
    }
    in++;
  }
  if(f){
    return 2;
  }
  f = 1;
  in = 0;
  for(int i = 0;i < v2.size(); i++){
    while(in < v1.size() && v1[in] < v2[i]){
      in++;
    }
    if(in >= v1.size()){
      f = 0;
      break;
    }
    in++;
  }
  if(f){
    return 1;
  }
  else{
    return 0;
  }
}
int main()
{

    int n,ans = 0;
    cin >> n;
    int ves,dir;
    while(n--){
      scanf("%d%d",&ves,&dir);

      if(dir == 1){
        if(v1.size() > 0){
          it = lower_bound(v1.begin(),v1.end(),ves);
          v1.insert(it,ves);
        }
        else{
          v1.push_back(ves);
        }
      }
      else{
        if(v2.size() > 0){
          it = lower_bound(v2.begin(),v2.end(),ves);
          v2.insert(it,ves);
        }
        else{
          v2.push_back(ves);
        }
      }
      if(ans == dir){
          if(dir == 1){
            puts(">");
          }
          else{
            puts("<");
          }
      }
      else{
      int f = fun(1);
      if(f == 0){
        ans = 0;
        puts("?");
      }
      else
      if(f == 1){
        ans = 1;
        puts(">");
      }
      else{
        ans = 2;
        puts("<");
      }
      }

    }
}
/*
7
1 1
2 2
3 1
4 2
5 1
6 2
7 1
*/

Compilation message

stones.cpp: In function 'int fun(int)':
stones.cpp:13:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i < v1.size(); i++){
                 ~~^~~~~~~~~~~
stones.cpp:14:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(in < v2.size() && v2[in] < v1[i]){
           ~~~^~~~~~~~~~~
stones.cpp:17:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(in >= v2.size()){
        ~~~^~~~~~~~~~~~
stones.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i < v2.size(); i++){
                 ~~^~~~~~~~~~~
stones.cpp:29:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(in < v1.size() && v1[in] < v2[i]){
           ~~~^~~~~~~~~~~
stones.cpp:32:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(in >= v1.size()){
        ~~~^~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:52:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d%d",&ves,&dir);
       ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 612 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 2 ms 612 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 6 ms 612 KB Output is correct
9 Correct 3 ms 612 KB Output is correct
10 Correct 58 ms 612 KB Output is correct
11 Execution timed out 1086 ms 1120 KB Time limit exceeded
12 Halted 0 ms 0 KB -