結果
| 問題 | No.1717 Levi-Civita Triangle | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2024-08-22 10:59:11 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 18 ms / 2,000 ms | 
| コード長 | 485 bytes | 
| コンパイル時間 | 613 ms | 
| コンパイル使用メモリ | 65,940 KB | 
| 最終ジャッジ日時 | 2025-02-23 23:17:50 | 
| ジャッジサーバーID (参考情報) | judge4 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 42 | 
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 scanf("%d",&a[i]);
      |                 ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <cstdio>
using namespace std;
const int N=1e5+5;
int n,a[2*N];
bool calc(){
	for(int i=0;i<n;i++)
		if((a[i]==0)^(i&1))
			return true;
	for(int i=2;i<n;i+=2)
		if(a[i-2]==a[i])
			return true;
	return false;
}
void solve(){
	scanf("%d",&n);
	n=n*2+1;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	if(a[1]){
		int x=3-a[1];
		for(int i=0;i<n;i++)
			a[i]=(a[i]+x)%3;
	}
	if(calc()) puts("0");
	else printf("%d\n",a[n-1]);
}
int main(){
	solve();
	return 0;
}
            
            
            
        