結果
| 問題 |
No.1717 Levi-Civita Triangle
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-05-27 21:25:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 1,060 bytes |
| コンパイル時間 | 1,622 ms |
| コンパイル使用メモリ | 161,684 KB |
| 実行使用メモリ | 10,152 KB |
| 最終ジャッジ日時 | 2025-05-27 21:25:15 |
| 合計ジャッジ時間 | 4,011 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:35:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | for(int i=1;i<=n;i++) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
typedef int IT;
typedef long long LL;
typedef __int128 int128;
typedef double DB;
typedef long double LDB;
#define pb push_back
#define fst first
#define sec second
#define psh push
#define mkp make_pair
#define PII pair<IT,IT>
#define PLI pair<LL,IT>
#define lowbit(x) ((x)&(-x))
using namespace std;
const int N=1e6+10,L=N<<1;
int f[3][3][3];
int n;
int a[L];
int g[L];
bool ans;
void sl_reset();
void solve(){
sl_reset();
scanf("%d",&n);
n=(n<<1)+1;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n-2;i++) g[i]=f[a[i]][a[i+1]][a[i+2]];
for(int i=1;i<=n-2;i++){
if(i&1){
ans&=(g[i]!=0);
if(i>1) ans&=(g[i]!=g[i-2]);
}
else ans&=(g[i]==0);
}
if(ans) printf("%d\n",g[n-2]);
else printf("0\n");
return;
}
void sl_reset(){
ans=1;
return;
}
int main(){
f[0][1][2]=f[1][2][0]=f[2][0][1]=1;
f[2][1][0]=f[1][0][2]=f[0][2][1]=2;
int T=1;
// scanf("%d",&T);
while(T--){
solve();
}
return 0;
}
vjudge1