CSES - NOI 2019 - Results
Submission details
Task:Thieves and Prisons
Sender:Ægir Örn Kristjánsson
Submission time:2019-03-06 16:00:04 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:34:9: error: expected primary-expression before ')' token
     if ()
         ^

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,k,m; cin>>n>>k>>m;

  bool prison[k];
  for (int i=0; i<k; i++) {
    prison[i]=false;
  }
  //0 ekki í fangelsi. Annað en 0 er númer hvaða fangelsi hann er í
  int thief[n];
  for (int i=0; i<n; i++) {
    thief[i]=0;
  }
 
  int ccount=0;
  int cinarow=0;
  int ocount=0;
  string ocevent[m];
  int tevent[m];
  bool impossible=false;
  int answer[m];

  for (int i=0; i<m; i++) {
    string oc;
    int t;
    cin>>oc>>t;
    ocevent[i]=oc;//Geymir hvort O eða C er notað í umferð
    tevent[i]=t;//Geymir hvaða fangi er notaður í umferð
  }

  for (int i=0; i<m; i++) {
    if ()
    if (cinarow==n||thief[tevent[i]-1]!=0) {
      impossible=true;
      break;
    }

    int u; //Geymir hvaða fangelsi er valið í umferðinni

    if (ocevent[i]=="C") {
      if (prison[0]==false&&prison[1]==false) {
        u=1;
      } else if (ocevent[i+1]=="O"&&ocevent[i+2]=="O") {
        u=2;
      } else if (ocevent[i+1]=="O"&&ocevent[i+2]=="O"&&ocevent[i+3]=="O") {
      } else {
        u=1;
      }
      answer[i]=u;
      prison[u-1]=true;
      thief[tevent[i]-1]=u;
      ccount++;
      cinarow++;
    } 
    
    else if (ocevent[i]=="O") {
      if (ocount==ccount) {
        impossible=true;
        break;
      } else if (prison[0]==false&&prison[1]==false) {
        impossible=true;
        break;
      } else if (prison[1]==true) {
        u=2;
      } else {
        u=1;
      }
      answer[i]=u;
      prison[u-1]=false;
      ocount++;
      cinarow=0;
      for (int i=0; i<k; i++) {
        if (thief[i]==u) {
          thief[i]=0;
        }
      }
    }
  }

  if (impossible) {
    cout<<"IMPOSSIBLE";
  } else {
    for (int i=0; i<m; i++) {
      cout<<answer[i]<<" ";
    }
  }
}